Entity Framework – Add Navigation Property Manually

Yup – it’s not that straightforward. Here’s what you do: 1 – Right click on the designer, Add -> Association 2 – Setup the association and cardinalities (People *..1 Gender, People *..1 Race) 3 – Go into the Model Browser -> Associations 4 – Right click on your newly created associations, click Properties 5 – … Read more

navigation property should be virtual – not required in ef core?

virtual was never required in EF. It was needed only if you want lazy loading support. Since Lazy loading is not yet supported by EF Core, currently virtual have no special meaning. It would when (and if) they add lazy loading support (there is a plan for doing so). Update: Starting with EF Core 2.1, … Read more

EF codefirst : Should I initialize navigation properties?

Collections: It doesn’t matter. There is a distinct difference between collections and references as navigation properties. A reference is an entity. A collections contains entities. This means that initializing a collection is meaningless in terms of business logic: it does not define an association between entities. Setting a reference does. So it’s purely a matter … Read more