简体   繁体   English

实体框架5混合了Oracle和SQL Server

[英]Entity Framework 5 mixing Oracle & SQL Server

I have 2 data layer DLL projects. 我有2个数据层DLL项目。 One is hitting Oracle tables and the other SQL Server. 一个是攻击Oracle表和另一个SQL Server。 Each one works on their own when used in separate projects. 当在单独的项目中使用时,每个人都可以独立工作。

When I make a project that includes both DLL's I get the following error when an Oracle table is queried: 当我创建一个包含两个DLL的项目时,我在查询Oracle表时收到以下错误:

Schema specified is not valid. 指定的架构无效。 Errors: Model.ssdl(2,48) : error 0172: 错误:Model.ssdl(2,48):错误0172:
All SSDL artifacts must target the same provider. 所有SSDL工件必须以同一提供商为目标。 The Provider 'Oracle.ManagedDataAccess.Client' is different from 'Oracle.ManagedDataAccess.Client' that was encountered earlier. Provider'Oracle.ManagedDataAccess.Client'与之前遇到的'Oracle.ManagedDataAccess.Client'不同。 Model.ssdl(2,81) : error 0169: All SSDL artifacts must target the same provider. Model.ssdl(2,81):错误0169:所有SSDL工件必须以同一提供程序为目标。 The ProviderManifestToken '2008' is different from '11.2' that was encountered earlier. ProviderManifestToken'2008'与先前遇到的'11 .2'不同。

The crazy thing is, in my 1 project that includes 2 data layers projects if I comment out a function that has usage of the SQL Server data layer (even though it never actually gets called at this time) then it works. 疯狂的是,在我的1个项目中包含2个数据层项目,如果我注释掉一个使用SQL Server数据层的函数(即使它此时从未实际调用过),那么它可以工作。 Somehow the presence of it's code causes this error above. 不知何故,它的代码存在会导致上述错误。 How can I mix SQL Server and Oracle entity framework? 如何混合SQL Server和Oracle实体框架?

My code started to work when I moved the Oracle DB connection and query into a separate method. 当我将Oracle数据库连接和查询移动到单独的方法时,我的代码开始工作。

I was under the impression that I should keep the Oracle connection open for all queries because it would be inefficient otherwise, but apparently this is actually done automatically under the hood. 我的印象是我应该为所有查询保持Oracle连接打开,因为否则效率低下,但显然这实际上是在引擎盖下自动完成的。 Now that the scope of the two connections are entirely separate it is working. 既然两个连接的范围完全是分开的,那么它就可以工作了。

Why? 为什么? No idea... 不知道...

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

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