Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaningful Names for Navigation Properties using Entity Framework

I am using the ADO .NET Entity Framework to import my model from a database. A table in my db has a bunch of foreign keys, all with abstract names e.g. FKDevice132610.

When I import the table into my model, it brings in navigation properties for each foreign key, however they are imported with names based on the table name they link to. If there is more than one foreign key to a certain table, a number is appended on the end.

Ef model

In this case Devices1 is ParentDevices and Devices2 is ChildDevices. Is there a way I can enter this information into my foreign key (say using the description or the name) so that the Entity Framework will import meaningful names for my navigation properties?

like image 447
dnatoli Avatar asked Sep 06 '11 00:09

dnatoli


1 Answers

As I know there is currently no way to do that. This is how current designer works. What is even worse when you rename these properties to correct names updating model from database will sometimes overwrite your changes.

Improvement of navigation property naming is tracked by this work item - http://entityframework.codeplex.com/workitem/125

like image 140
Ladislav Mrnka Avatar answered Oct 21 '22 11:10

Ladislav Mrnka