我正在学习these video series之后使用VS2013来制作ASP.Net MVC Web应用程序。当出现以下错误时:
找不到为ADO.NET提供者提供的Entity Framework提供者,不变名称“ 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'部分中注册。的应用程序配置文件”。)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.???
写什么,并且已经停留了几个小时。如果我不放,则会收到以下警告:
缺少必需的属性“类型”
对此将提供任何帮助。
如果您知道除了添加提供程序来解决此问题之外还需要做其他事情,我也很乐意。我在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>
Oracle.ManagedDataAccess
[但是,当我检查接受的答案所指的文档时,我没有发现提示回答者写了什么的陈述,这使我相信,到目前为止,Oracle.ManagedDataAccess
可能已经在EF 6中得到支持。] >
然后我发现this document包含许多技巧,可以解决在EF 6中使用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>
((我使用的是Oracle.ManagedDataAccess
版本4.121.2.0)
[实体框架提供者
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
Web.config
文件中的全部