我正在学习在these video series之后使用VS2013制作ASP.Net MVC Web应用程序。当我收到以下错误时:
找不到ADO.NET提供程序的实体框架提供程序 不变名称'Oracle.ManagedDataAccess.Client'。确保 提供者是在'entityFramework'部分注册的 应用配置文件。看到 http://go.microsoft.com/fwlink/?LinkId=260882了解更多信息。
(在视频中,使用的数据库提供程序是ASP.Net应用程序的自然System.Data.SqlClient
,但我需要使用Oracle.ManagedDataAccess.Client
)
错误本身在SO中为not new。并且,正如错误消息和SO问题的接受答案所示,我检查了EF 6.0是否支持ODP.Net提供程序,我发现it is。然而,我仍然无法使其发挥作用。
我对MVC很陌生,所以如果有任何MVC应用程序/设置的概念,我在这一点上错误地理解并且我对你的更正持开放态度。
其他可能有用的信息:
app.config
文件,但有Web.config
文件(这有什么不同吗?在错误消息中建议“确保提供商已注册'entityFramework'部分
应用程序配置文件“。)在Web.config文件中,我找到了以下entityFramework
部分:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
我注意到有
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />`
在那里排队。因此我尝试类似地添加:
<provider invariantName="Oracle.ManagedDataAccess.Client" type=???, EntityFramework.???" />
但是我不知道为type
属性和EntityFramework.???
写什么,并且已经停留了几个小时。如果我不说,我收到以下警告:
缺少必需的属性“type”
对此的任何帮助将不胜感激。
如果您知道除了添加提供程序以解决此问题之外还需要做任何其他事情,我也是开放的。我在web.config
文件中的连接字符串如下:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcWebApplication1-20160212010850.mdf;Initial Catalog=aspnet-MvcWebApplication1-20160212010850;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="EmployeeContext" connectionString="Data source=aaaaa;user id=bbbbbb;password=cccccc;persist security info=True" providerName="Oracle.ManagedDataAccess.Client"/>
</connectionStrings>
答案 0 :(得分:0)
我从an Oracle's ODP.Net document和an Oracle Community forum获得了答案:
显然,根据接受的答案,直到2014年初,ODAC不支持EF document中所述。必须部分使用EF 5才能使用url('path/to/image.jpg')
但是,当我检查接受的答案所指的文件时,我没有找到表明回答者所写内容的陈述 - 让我相信到目前为止,Oracle.ManagedDataAccess
可以在EF中得到支持6。
然后我发现this document包含了很多技巧来解决在EF 6中使用Oracle.ManagedDataAccess
时可能出现的问题。
特别适用于我的是添加:
配置文件
Oracle.ManagedDataAccess
依赖大会
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
(我使用<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0" />
</dependentAssembly>
版本4.121.2.0)
实体框架提供商
Oracle.ManagedDataAccess
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
文件中的所有内容