我有一个MVC项目,引用了两个单独的项目,每个项目都包含一个edmx。 两个EDMX项目中的每一个都指向不同的数据库。 这两个数据库具有相同名称的表 - 例如联系人。 我需要两者,有时在同一个控制器中。
我设置了两个不同的上下文,但我得到错误“contact是mode1.contact和model2.contact之间的模糊引用。
如何使用具有相同实体名称的两个数据上下文?
I have an MVC project with references to two seperate projects, each of which contains an edmx. Each of the two EDMX projects point to a different database. The two databases have tables with identical names - contacts for instance. I need both, sometimes in the same controller.
I've set up two different contexts, but I get the error "contact is an ambiguous reference between model1.contact and model2.contact.
How can I use two data contexts that have identical entity names?
最满意答案
尝试使用完全限定的命名空间,看看会发生什么。 如果你讨厌太长的命名空间为命名空间分配一个别名
try to use fully qualified namespace and see what happens. if you hate too long namespace assign an alias for namespace
更多推荐
发布评论