Problems switching .NET project from unmanaged to managed ODP.NET assemblies

与世无争的帅哥 提交于 2019-12-04 17:37:17

Manual Download Method

Thanks to @Christian Shay for pointing out that the NuGet version of Managed ODAC is not authored by Oracle

To use Managed Oracle Data Access with Entity Framework, in Visual Studio 2012 (.NET 4.5):

  1. Pull down Entity Framework 5.0.0.0

    Install-Package EntityFramework -Version 5.0.0

  2. Download the latest Oracle Data Access Components (ODAC)

  3. Manually reference Oracle.ManagedDataAccess.dll

  4. Add this section to the config file

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <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>

And then proceed as usual. It appears at this time that Entity Framework 6 does not support Oracle.ManagedDataAccess yet, so it is necessary to run version 5.

Also keep in mind that if you are using Visual Studio 2010 or earlier, targeting .NET 4, NuGet will pull down EF5, but use the 4.x assemblies. I have not tested this on VS2010 with .NET 4.

Unofficial NuGet Method

To use Managed Oracle Data Access with Entity Framework, in Visual Studio 2012 (.NET 4.5):

  1. Pull down Entity Framework 5.0.0.0

    Install-Package EntityFramework -Version 5.0.0

  2. Pull down Oracle Data Provider for .NET (ODP.NET) Managed Driver

    Install-Package odp.net.managed

  3. Add this section to the config file

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <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>

And then proceed as usual. It appears at this time that Entity Framework 6 does not support Oracle.ManagedDataAccess yet, so it is necessary to run version 5.

Also keep in mind that if you are using Visual Studio 2010 or earlier, targeting .NET 4, NuGet will pull down EF5, but use the 4.x assemblies. I have not tested this on VS2010 with .NET 4.

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