*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.

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.


In the designer, you can set the navigation properties as having Private getters/setters. While they will still be there, because Entity Framework (by default) does lazy loading, it won't actually retrieve any data from the database at runtime. And they won't respawn the next time you update the model from the database.


Need Your Help

Return SQL Query as Array in Powershell

sql-server arrays sql-server-2008 powershell

I have a SQL 2008 Ent server with the databases "DBOne", "DBTwo", "DBThree" on the server DEVSQLSRV.

Your web browser must have JavaScript enabled in order for this application to display correctly

java swing

I displayed webpage on JEditorPane, but it is getting message as "Your web browser must have JavaScript enabled in order for this application to display correctly."