Entity Framework Code First and Oracle ODAC 12c Release 3 Error

左心房为你撑大大i 提交于 2019-12-12 01:29:42

问题


A bit stumped with this one...

I'm receiving the following error when setting up Code First on Entity Framework and Oracle...

No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.ManagedDataAccess.Client'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

With the following setup...

Entity Framework 6.1.1

ODAC 12c Release 3

Any ideas on how to fix this problem?

I've included the app.config file below...

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
   <connectionStrings>
    <add name="Context" connectionString="DATA SOURCE=****;PASSWORD=****;PERSIST SECURITY INFO=True;POOLING=False;USER ID=SYSTEM" providerName="Oracle.ManagedDataAccess.Client" />
  </connectionStrings> 
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

回答1:


since you have used a providerName Oracle.ManagedDataAccess.Client in connectionString. you need to add a line in following section to define it:

<providers>  
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices,OracleManagedDataAccess.EntityFramework" />
</providers>



回答2:


Am trying to do the same . but not working with me either , Did you managed to make it work ?

Try to add the provider to your config file :

   <providers>
      <provider invariantName="Oracle.ManagedDataAccess.Client" 
                type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </providers>

Also check this link https://community.oracle.com/message/12679686




回答3:


After messing today for a few hours with the same error I found that I missed to select the correct T4 templates (see step #3)

  1. Install "ODAC 12c Release 3 and Oracle Developer Tools for Visual Studio"

    Btw. I found this note on a Oracle website:

    Note: If you have installed ODAC 12c Release 3 configured on a machine-wide level, you will see an error when trying to generate database scripts using Entity Framework Model-First. To resolve this issue, use an ODAC version later than this release or reinstall ODAC 12c Release 3 with the "Configure ODP.NET at a machine-wide level" box UNchecked.

  2. Add those nuget packages to you project:

    • EntityFramework (6.1.3 here)
    • Offical Oracle ODP.NET, Managed Entity Framework Driver (12.1.022 here)

    Those will also add some dependent packages and insert the necessary configuration into the App.config.

  3. Before generating the database, choose the correct T4 templates in the properties of the EDMX model before generating the database.

The pre-selected templates are designed for MS SQL Server (I guess).



来源:https://stackoverflow.com/questions/26393938/entity-framework-code-first-and-oracle-odac-12c-release-3-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!