This question already has an answer here:
这个问题在这里已有答案:
- Meaningful Names for Navigation Properties using Entity Framework 3 answers
- 使用Entity Framework 3答案的导航属性的有意义名称
I have a table that has two foreign keys to the same table... When I'm trying to add or update Entity Framework model it generates something like this:
我有一个表有两个外键到同一个表...当我试图添加或更新实体框架模型时,它生成这样的东西:
public virtual SystemDefinition SystemDefinition { get; set; }
public virtual SystemDefinition SystemDefinition1 { get; set; }
public virtual SystemDefinition SystemDefinition2 { get; set; }
Everything works fine for me but tbh I hate default object names e.g. "SystemDefinition1" and "SystemDefinition2" etc... I can rename it and it also will work fine, but when i try to update entity model(or delete and add it again), it still generates this default names. (Also if I "Run custom tool")... Could you please explain, how do I avoid renaming? Where and how can I set default names for objects?
一切都适合我,但我讨厌默认的对象名称,例如“SystemDefinition1”和“SystemDefinition2”等...我可以重命名它也可以正常工作,但是当我尝试更新实体模型(或删除并再次添加)时,它仍会生成此默认名称。 (另外,如果我“运行自定义工具”)...请解释一下,我该如何避免重命名?我在哪里以及如何设置对象的默认名称?
Thanks
谢谢
1 个解决方案
#1
0
For this you must use exactly same column name of 1st table which is foreign key to the 2 nd table
为此,您必须使用第一个表的完全相同的列名,这是第二个表的外键
public virtual SystemDefinition 1stTableColumnName { get; set; }
#1
0
For this you must use exactly same column name of 1st table which is foreign key to the 2 nd table
为此,您必须使用第一个表的完全相同的列名,这是第二个表的外键
public virtual SystemDefinition 1stTableColumnName { get; set; }