Giter Club home page Giter Club logo

entityframework.graphmanager's Introduction

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 Ma.EntityFramework.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  Ma.EntityFramework.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 Ma.EntityFramework.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.

entityframework.graphmanager's People

Contributors

mammadovadil avatar

Stargazers

Samir Isagov avatar Farhad Jabiyev avatar

Watchers

James Cloos avatar Imranov Farid avatar Natiq Qaraisayev avatar  avatar

Forkers

markchipman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.