Why Navigation Properties are virtual by default in EF

If you define your navigation property virtual, Entity Framework will at runtime create a new class (dynamic proxy) derived from your class and uses it instead of your original class. This new dynamically created class contains logic to load the navigation property when accessed for the first time. This is referred to as “lazy loading”. … 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

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)