The one-to-many EF Lazy-Load pattern

If we take a wider look at the amount of source code we have written, we can easily note how each Foreign Key spawned:

  • A single-object entity property with the same type of the entity we’re referring to in the class containing the Foreign Key
  • A type-defined listing property in the related class

This pattern won’t change as long as we’re defining one-to-many relationships only; an object to the left, leading to a list of related objects to the right.

Are we done with our entities? Yes. Are we ready to deploy our code-first Database? Hardly. Before doing that, we need to take care of two more things:

  1. Set up an appropriate Database Context.
  2. Enable the Code-First Migrations support within our project.

Let’s do that right now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.42.243