使用实体框架有意义的名称导航属性 [英] Meaningful Names for Navigation Properties using Entity Framework

查看:181
本文介绍了使用实体框架有意义的名称导航属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是ADO .NET实体框架从数据库导入我的模型。在我的数据库的表有一堆的外键,全部采用抽象的名字,例如 FKDevice132610

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.

在这种情况下Devices1是ParentDevices和设备2是ChildDevices。有没有一种方法,我可以将此信息输入到我的外键(比如使用说明或名称),以使实体框架将导入一个有意义的名字为我的导航属性?

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?

推荐答案

据我所知,目前还没有办法做到这一点。这就是目前的设计师作品。当您重命名这些属性来纠正名更新型号从数据库中有时会覆盖更改更糟。

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.

的导航属性命名的改进是由该工作项跟踪 - HTTP://entityframework.codeplex.com /工作项/ 125

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

这篇关于使用实体框架有意义的名称导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆