O'Reilly logo

Fluent Entity Framework by Rebecca M. Riordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding entities

At its simplest, creating a new instance of an entity is like creating a new instance of any .NET object: You simply call a constructor.

There’s nothing special about creating an entity instance. You’ve been doing it all along  by calling its constructor:

Image

The default code generation strategy for the Designer creates a factory method that accepts all required (not-nullable) properties as parameters. Of course, you create a method like this yourself if you’re using the Code First workflow:

Image

The context doesn’t watch entity creation, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required