简体   繁体   English

如何修复动态数据中的类型名称冲突

[英]How to fix type names conflicts in Dynamic Data

We're working in a Dynamic Data project that will handle entities coming from two different namespaces: myModel.Abby and myModel.Ben . 我们正在开发一个动态数据项目,该项目将处理来自两个不同名称空间的实体: myModel.AbbymyModel.Ben

whose classes are: 其班级是:


Abby 艾比

myModel.Abby.Car

myModel.Abby.Lollipop

Ben

myModel.Ben.Car

myModel.Ben.Apple

So myModel.Abby.Car and myModel.Ben.Car are homonym. 所以myModel.Abby.CarmyModel.Ben.Car是谐音。 when I try to register both ObjectContext 's, an exception is thrown telling us that there are type name conflicts between the mentioned classes (although the types belong to different namespaces). 当我尝试注册两个ObjectContext ,会抛出一个异常,告诉我们所提到的类之间存在类型名称冲突(尽管这些类型属于不同的名称空间)。

How can we overcome type-name conflicts, caused by repeated type names among different namespaces? 我们如何克服由不同命名空间中重复的类型名称引起的类型名称冲突?

I don't think there is a way around this. 我认为没有办法解决这个问题。

DynamicData routes to the correct forms based on type names. DynamicData根据类型名称路由到正确的表单。 Look in the URL, the type name is always up there someplace. 在URL中查找,类型名称总是在某处。 How can DD know which type you mean to interact with? DD如何知道您要与哪种类型进行交互?

Here is a workaround from MSDN 这是MSDN的解决方法

The problem is a naming conflict between types in 2 different contexts. 问题是两种不同上下文中类型之间的命名冲突。 To get around this you can rename one of the classes specifying the TableNameAttribute on your entity. 要解决此问题,您可以重命名其中一个类,指定实体上的TableNameAttribute。

Hope it helps others. 希望它能帮助别人。 : ) :)

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

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