简体   繁体   English

数据优先EF,系统表与系统命名空间冲突

[英]Data First EF, System Table clashes with System Namespace

I'm developing a .NET project and am incorporating a data-first link with a database. 我正在开发.NET项目,并将数据优先链接与数据库合并在一起。 Unfortunately, the database has a mandatory table called "System", and the generated class in the model is clashing with the System namespace, overriding it. 不幸的是,数据库有一个称为“ System”的强制性表,并且模型中生成的类与System名称空间冲突,将其覆盖。 I have tried commenting out the class and all references to it, but then the Context throws missing relationship errors. 我尝试注释掉该类及其所有引用,但是随后Context抛出缺少的关系错误。 Any ideas on resolving this conflict? 解决这个冲突有什么想法吗?

I am new to data-first EF, so I'm sure there must be some work around I'm not familiar with. 我是数据优先EF的新手,所以我敢肯定我周围不熟悉一些解决方法。 Perhaps renaming the class and all its references within the class, but mapping it to the correct table in the context/edmx? 也许重命名该类及其在类中的所有引用,但将其映射到context / edmx中的正确表? I'm not sure how to do that though. 我不知道该怎么做。 I'm using EF 6.2. 我正在使用EF 6.2。

You can change the name in the EDMX designer. 您可以在EDMX设计器中更改名称。 That will rename the class and keep it mapped to the System table. 这将重命名该类,并将其映射到System表。 – Gert Arnold –格特·阿诺德

This was the correct answer. 这是正确的答案。 Intellisense didn't volunteer to fix the class names for me after renaming in the EDMX, so I had to spend 15 minutes updating the class, its references, and the 20ish times it was referenced in the EDMX file itself. 在EDMX中重命名后,Intellisense并没有自愿为我修复类名,因此我不得不花15分钟来更新类,其引用以及在EDMX文件本身中引用20倍的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM