使用ef6创建oracle数据库的实体模型遇到的问题及

解决方案中的数据层项目最初使用的是oracle 11g + ef5 创建的实体模型,在分页时遇到了skip参数为0报错的问题,没有找到相关资料。

于是决定升级到ef6,在oracle官网中得知,Oracle Data Provider for .NET in ODAC 12c Release 3 开始支持ef6(https://docs.oracle.com/cd/E56485_01/win.121/e55744/release_changes.htm#CIHGIAEG)

安装步骤:

1.安装odac,下载地址http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-087491.html

2.数据层项目的.net版本改成4.5以上,使用nuget安装 EntityFramework 6 +Oracle.ManagedDataAccess +Oracle.ManagedDataAccess.EntityFramework,都安装最新稳定版。

安装后app.config和web.config都会被加入如下配置项

<configSections>
 <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
 </configSections>
 <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" />
  <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
 </providers>
 </entityFramework>
 <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.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
 </DbProviderFactories>
 </system.data>
 <runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
  <publisherPolicy apply="no" />
  <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
  </dependentAssembly>
 </assemblyBinding>
 </runtime>
 <oracle.manageddataaccess.client>
 <version number="*">
  <dataSources>
  <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />
  </dataSources>
 </version>
 </oracle.manageddataaccess.client>
      

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/5180.html