EntityFrameworkCore.GraphManager 7.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EntityFrameworkCore.GraphManager --version 7.1.0                
NuGet\Install-Package EntityFrameworkCore.GraphManager -Version 7.1.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="7.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntityFrameworkCore.GraphManager --version 7.1.0                
#r "nuget: EntityFrameworkCore.GraphManager, 7.1.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=7.1.0

// Install EntityFrameworkCore.GraphManager as a Cake Tool
#tool nuget:?package=EntityFrameworkCore.GraphManager&version=7.1.0                

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:

  1. Your mapping classes should intherit ExtendedEntityTypeConfiguration<TEntity>, where TEntity 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.
  2. Add EntityFrameworkCore.GraphManager to your usings section where to you want to add or update entities.
  3. 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 Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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

Migrate to .Net 7