Nervestaple.EntityFrameworkCore 0.5.1

dotnet add package Nervestaple.EntityFrameworkCore --version 0.5.1
                    
NuGet\Install-Package Nervestaple.EntityFrameworkCore -Version 0.5.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nervestaple.EntityFrameworkCore" Version="0.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nervestaple.EntityFrameworkCore" Version="0.5.1" />
                    
Directory.Packages.props
<PackageReference Include="Nervestaple.EntityFrameworkCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nervestaple.EntityFrameworkCore --version 0.5.1
                    
#r "nuget: Nervestaple.EntityFrameworkCore, 0.5.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nervestaple.EntityFrameworkCore@0.5.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nervestaple.EntityFrameworkCore&version=0.5.1
                    
Install as a Cake Addin
#tool nuget:?package=Nervestaple.EntityFrameworkCore&version=0.5.1
                    
Install as a Cake Tool

Continuous Integration

Nervestaple.EntityFrameworkCore

This project provides library code to make it easier to code up repositories backed by databases using Microsoft's EntityFrameworkCore library. All of the code needed to handle the icky stuff has already been coded up, all you need to do is write up the "entity" class and extend the provided repositories. You may use the fluent API if you prefer but these examples use annotations.

public class ToDoItem : Entity<long>
{
    public override long? Id { get; set; }
    
    public long? ToDoContextId { get; set; }
    
    [ForeignKey("ToDoContextId")]
    public ToDoContext ToDoContext { get; set; }
    
    ...
}

In this example we extent the provided Entity class and specify the unique identifier column type (long) and then code up the properties, including an example relationship. We also have the concept of an EditModel, this is in place to support situations where you have an entity with many fields but not all of them are editable (i.e. collection properties).

public class ToDoItemEdit : EditModel<ToDoItem, long>
{
    /// <summary>
    /// Unique ID of the instance
    /// </summary>
    public long? Id { get; set; }
    
    /// <summary>
    /// The unique ID of this instance's context
    /// </summary>
    public long? ToDoContextId { get; set; }
    ...
}

You may also code up Criteria and Parameter classes to get searching of entity fields by string, date range, numeric range, etc.

With that out of the way, we can code up our repository. In real-life you'd probably have an interface for your repository as well.

public class ToDoItemRepository : ToDoReadWriteRepository<ToDoItem, long>, IToDoItemRepository
{
    public ToDoItemRepository(ToDoDbContext context) : base(context)
    {
        
    }
}

We extend the provided repository and fill in our context. You get the CRUD methods for free! We have a larger (and runnable) example you can look at to get a better idea how things work for real.

Documentation

This project uses Doxygen for documentation. Doxygen will collect inline comments from your code, along with any accompanying README files, and create a documentation website for the project. If you do not have Doxygen installed, you can download it from their website and place it on your path. To run Doxygen...

$ cd src
$ doxygen

The documentation will be written to the doc/html folder, you can read this documentation with your web browser.

Other Notes

Project Icon made by Freepik from Flaticon under the Creative Commons license.


Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Nervestaple.EntityFrameworkCore:

Package Downloads
Nervestaple.WebService

Wraps Nervestaple.EntityFrameworkCore to help create database backed web services

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.1 620 3/25/2022