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

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

问题描述

我正在使用ADO .NET实体框架从数据库导入我的模型。我的数据库中的一个表有一堆外键,全部是抽象的名字。

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,Devices2为ChildDevices。有没有办法可以将这些信息输入我的外键(比如使用说明或名称),以便Entity Framework导入导航属性的有意义的名称?

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.

此工作项目跟踪导航属性命名的改进 - a href =http://entityframework.codeplex.com/workitem/125 =nofollow> http://entityframework.codeplex.com/workitem/125

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

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

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