实体框架异常:发现歧义匹配 [英] Entity Framework Exception: Ambiguous match found

查看:62
本文介绍了实体框架异常:发现歧义匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了错误:


发现歧义匹配项

Ambiguous match found

在.Add

var db = new NexusEntities(); 
db.Reports.Add(mmr);

从谷歌搜索看来,如果有两个同名但不同的类似乎是个问题命名空间。据我所知不是这种情况。是否还有其他原因导致此错误发生?还是有办法告诉它要查找哪个参数?

From googling it appears to be an issue if the there are two classes with the same name but in different namespaces. As far as I can tell this is not the case... Is there another reason why this error can happen? Or is there a way to tell which parameter it is finding two of?

推荐答案

这是EF中的弱点。当相同的属性出现在类/子类型层次结构中时,就会发生这种情况。

This is a "weakness" in EF. It happens when the same property appears in class / subtype hierarchy.

很可能您有一个隐藏字段。即已重新定义的属性。
当EF寻找a属性时,它也必须使用类型/基础树来查找属性。但是,如果它在树中两次找到它,则将其解释为重复项。 EF不仅使用最低的最具体替代。

Most likely you have a hidden field. i.e. a property that has been redefined. When EF looks for the a property it too must use the type/base tree to find the property. But if it finds it twice in the tree, it interprets this as a duplicate. EF doesnt just use the lowest most specific override.

因此,使用EF无法隐藏属性。

So property hiding is not possible with EF.

检查您的课程,某个地方会出现两次财产。

Check your classes, a property will occur twice somewhere.

这篇关于实体框架异常:发现歧义匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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