如何首先使用Entity Framework数据库引用两个数据库?(How can I reference two databases using Entity Framework database

编程入门 行业动态 更新时间:2024-10-28 05:25:29
如何首先使用Entity Framework数据库引用两个数据库?(How can I reference two databases using Entity Framework database first?)

我有一个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

更多推荐

本文发布于:2023-07-08 05:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1072495.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   两个   Framework   Entity   databases

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!