EntityFrameworkCore.GraphManager
9.0.0
dotnet add package EntityFrameworkCore.GraphManager --version 9.0.0
NuGet\Install-Package EntityFrameworkCore.GraphManager -Version 9.0.0
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="EntityFrameworkCore.GraphManager" Version="9.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntityFrameworkCore.GraphManager --version 9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EntityFrameworkCore.GraphManager, 9.0.0"
#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.
// Install EntityFrameworkCore.GraphManager as a Cake Addin #addin nuget:?package=EntityFrameworkCore.GraphManager&version=9.0.0 // Install EntityFrameworkCore.GraphManager as a Cake Tool #tool nuget:?package=EntityFrameworkCore.GraphManager&version=9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Important Note
This repo has been created by migrating from EntityFramework.GraphManager repo. Readme file is outdated and needs to be updated.
Introduction
Automatically handle and define state of complex hierarchical graph of entities for EntityFramework Code-First.
Prerequisite
- This API should be used with EntityFramewok Code-First
- You should be familiar with Fluent API (quick introduction).
- Add explicit foreign key properties to your models. If we do not add explicit property and configure it as foreign key, then entity framework will create it for us. But, we have to create it ourselves.
public class Post
{
// Foreign key to Blog must exist
public int BlogID { get; set; }
public Blog Blog { get; set; }
}
- Additionally, if you have many-to-many relationships, you should create model for third table. For example, if you have Student and Course models, and if there is many-to-many relation between them, you should also create model for relating third table, which porbably will be StudentCourse. Then Student and StudentCourse, Course and StudentCourse models will have one-to-many relationships. This will help a lot when we want to change which Students attend which Courses (add, update or delete.).
Features:
- Automatically define state of entity graph with ease.
- Use not only primary keys, but also configured unique keys to define state.
- Simple and complex unique keys.
- Send update query for only changed properties.
- Handle entity duplications according to primary and unique keys.
- Familiar Fluent API style mappings.
- Additional customization options to not update certain properties which shouldnot change.
- Manual operations after automatic state define.
Installation:
Install from nuget:
Install-Package EntityFrameworkCore.GraphManager
Usage:
- Your mapping classes should intherit
ExtendedEntityTypeConfiguration<TEntity>
, whereTEntity
is type of entity which you are configuring mappings for. To be able to do so, you have to add EntityFrameworkCore.GraphManager.CustomMappings namespace to unsings section. Remember that, you do not have to inherit this configuration class if you do not need any custom mappings (i.e. unique keys, not updated properties and etc.). Automatic state defining should still work without this. - Add EntityFrameworkCore.GraphManager to your usings section where to you want to add or update entities.
- Define state of whole graph using just one line:
context.AddOrUpdate(entity);
Further reading:
- Be sure to check out Wiki section soon for detailed documentation.
- Check out Code Project article for step-by-step sample application and more.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Ma.ExtensionMethods (>= 9.0.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Data.DataSetExtensions (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 20 | 11/15/2024 |
7.1.0 | 217 | 12/14/2023 |
7.1.0-beta.1 | 130 | 11/1/2023 |
7.0.5-beta.1 | 91 | 5/17/2023 |
Upgrade to .Net 9