2012-04-27 79 views
4

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

这里的实体连接信息(在相同的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,并且工作正常。

回答

3

我有一个类似的问题:Win7的64位DevArt与32位Oracle。

适用于web项目的Any CPU,但对控制台和单元测试项目失败。我通过在Debug模式下设置x86进行测试和控制台程序,将其固定为(或解决此问题)

0

我有同样的问题。对于我来说,解决这个问题的方法是在Platform Target下面的Project properties - > Build - >中取消选中'Prefer 32-bit'复选框。我的平台目标被设置为'任何CPU'。