I have a database where many of the tables have createdBy/modifiedBy columns that are foreign keys into a User table. When I update my model from the database, it generates navigation properties for all of these relationships. The User entity ends up with dozens of collections to navigate these relationships.
When I update the model from the database, I have the option to "Include foreign key columns in the model". If I un-check it, I get the navigation properties, but not the foreign key fields. Is there a way to generate the opposite, keep the foreign key fields, but don't add the navigation properties?
I'm new to 开发者_开发技巧Entity Framework, so I apologize if my question highlights my ignorance.
No there is not such option. You must manually delete navigation properties from User
entity. It should not add them again once you update model from database.
This is a painful situation - currently when I update the model from db and add a new table all the pesky navigation properties come back. Does anyone else have an idea of how to strip out all the FK references and Navigation properties?
The closest answer I have found is customizing the T4 code generation here: http://blogs.msdn.com/b/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx
精彩评论