Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

*Not* using navigation properties with Entity Framework?

Does anyone know if it's possible to not use the navigation properties feature of the entity framework for tables linked with a foreign key?

for example, if my client table has an AddressId, I want that AddressId in my model, I don't want it to have a .Address property. But I have thus far been unable to figure out how to do this.

like image 865
Joel Martinez Avatar asked Dec 03 '08 14:12

Joel Martinez


People also ask

How do I use navigation properties in Entity Framework?

A navigation property is an optional property on an entity type that allows for navigation from one end of an association to the other end. Unlike other properties, navigation properties do not carry data. A navigation property definition includes the following: A name.

What is navigation property in EF core?

Navigation property: A property defined on the principal and/or dependent entity that references the related entity. Collection navigation property: A navigation property that contains references to many related entities.

How do I use lazy loading in Entity Framework?

Lazy loading means delaying the loading of related data, until you specifically request for it. When using POCO entity types, lazy loading is achieved by creating instances of derived proxy types and then overriding virtual properties to add the loading hook.

What are scalar and navigation properties in Entity Framework?

Basically a scalar property is mapped to a column (int, string, ...) A navigation property is mapped to a relation. e.g Order. OrderDetails brings you to all ORderDetails of a specific order.


1 Answers

Sure, you can do this. It's just that the designer won't help you very much. Delete the navigation property, and add a scalar property for AddressId. It will work, but you'll have to be careful about hitting Update Model in the designer, as it may try to "fix" things for you. It's worth getting used to editing EDMX; it's not that bad.

like image 78
Craig Stuntz Avatar answered Oct 20 '22 05:10

Craig Stuntz