* Not * using navigation properties with Entity Framework?

Does anyone know if it is possible to use the navigation properties function for an entity structure for tables associated with a foreign key?

for example, if my client table has AddressId, I want AddressId in my model, I do not want it to have the .Address property. But so far I have not been able to figure out how to do this.

+7
entity-framework
source share
2 answers

Of course you can do it. Just a designer will not help you. Remove the navigation property and add the scalar property for AddressId. It will work, but you need to be careful in hitting the Update Model in the designer, as it may try to “fix” things for you. Get used to editing EDMX; it's not so bad.

+6
source share

In the designer, you can configure the navigation properties as having private recipients / setters. Although they will still be there because the Entity Framework (by default) performs lazy loading, it will not actually retrieve data from the database at run time. And they will not occur the next time the model is updated from the database.

0
source share

All Articles