Creating an Entity Framework model from a database without navigation properties

I have a database where many tables created By / modifiedBy columns, which are foreign keys in the User table. When I update my model from the database, it generates navigation properties for all of these relationships. A custom object ends with dozens of collections to navigate these relationships.

When I update the model from the database, I have the option "Include foreign key columns in the model." If I remove it, I will get navigation properties, but not foreign key fields. Is there a way to create the opposite, save foreign key fields, but not add navigation properties?

I am new to Entity Framework, so I apologize if my question emphasizes my ignorance.

+3
source share
2 answers

There is no such option. You must manually remove the navigation properties from the object User. It should not add them again as soon as you update the model from the database.

0
source

This is a painful situation: currently, when I update the model from db and add a new table, all the unpleasant navigation properties are returned. Does anyone else have an idea on how to remove all FK links and navigation properties?

The closest answer I found is to configure the T4 code generation here: http://blogs.msdn.com/b/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx

0
source

All Articles