The Entity Framework provider type 'Oracle.Man

2019-02-23 19:40发布

问题:

I am trying to connect to Oracle using the Oracle Data Provider.NET (ODP.NET) using Entity Framework v6 in an MVC application.

I have installed ODP.NET from here: https://www.nuget.org/packages/odp.net.entityframework/6.121.1-beta

I have configured my web.config file as follows:

<connectionStrings>
    <add name="MyDB" connectionString="User ID=MyUser;Password=MyPassword;Data Source=MyDatabase; Persist Security Info=False" providerName="Oracle.ManagedDataAccess" />
</connectionStrings>



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

However, when I try to call my EF Context, I get the following error:

The Entity Framework provider type 'Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' registered in the application config file for the ADO.NET provider with invariant name 'Oracle.ManagedDataAccess.EntityFramework' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application

I have spent a lot of time searching for help with this. Would be very grateful for any help!

Thanks!

Martin

回答1:

Adding this section to the web.config, along with the steps above, seems to have fixed this:

<system.data>

    <DbProviderFactories>

      <add name="ODP.NET, Managed Driver"
           invariant="Oracle.ManagedDataAccess.Client"
           description="Oracle Data Provider for .NET, Managed Driver"
           type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>

</system.data>


回答2:

There can be your framework problem. Please check your framework by right clicking on project--> properties check it is 4.5 version.

And then right click on Refrences--> Manage NuGet Package.. go to the nuget.org and type "Official Oracle ODP.NET" in search box. and install Official Oracle ODP.NET, Managed Entity Framework.
Official Oracle ODP.NET, Managed Driver. Oracle Data Provider for .Net x84/x64.

Thanking you