4

我已经使用 DevArt 的提供程序针对 Oracle 数据库设置了 Entity Framework 4.3。我在通过 NUnit 2.6 测试运行程序中的单元测试项目连接到数据库时遇到问题。有趣的是,我有一个 ASP.NET MVC 3 项目连接到它就好了。我在我的类库单元测试项目中创建了一个 App.config 并将实体连接字符串信息复制到它。我错过了什么?

这是实体连接信息(在 Web.config 和 App.config 中相同):

  <connectionStrings>
    <add name="Entities" connectionString="metadata=res://*/Entities.MagellanDataModel.csdl|res://*/Entities.MagellanDataModel.ssdl|res://*/Entities.MagellanDataModel.msl;provider=Devart.Data.Oracle;provider connection string=&quot;User Id=theusername;Password=thepassword;Server=theTNSname&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

这是异常信息:

AppName.Tests.AccountRepositoryTests.GetByContactId:
System.Data.EntityException : The underlying provider failed on Open.
----> System.InvalidOperationException : Can not obtain Oracle client information
      from registry. Make sure that Oracle Client Software is installed, or use 
      Direct mode of connecting to server.

注意:Web 和单元测试程序集都设置为编译为Any CPU. 我在 64 位 Windows 7 上运行 32 位 Oracle 10g 数据库。我发现一篇文章似乎表明它与需要 x86 的平台有关,但我的 Web 项目设置为Any CPU并且运行良好。

4

2 回答 2

3

我有一个类似的问题:Win7 64-bit DevArt with 32bit Oracle。

适用Any CPU于 Web 项目,但不适用于控制台和单元测试项目。我通过在模式下设置测试和控制台 projs 来修复它(或解决它) 。x86Debug

于 2012-04-28T12:16:41.167 回答
0

我遇到过同样的问题。对我来说,通过取消选中项目属性 -> 构建 -> 平台目标下方的“首选 32 位”复选框来解决此问题。我的平台目标设置为“任何 CPU”。

于 2014-11-04T21:02:11.290 回答