xml地图|网站地图|网站标签 [设为首页] [加入收藏]

步骤及遇到的问题

2019-10-01 12:18栏目:编程
TAG:

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

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

于是决定升级到ef6,在oracle官网中得知,Oracle Data Provider for .NET in ODAC 12c Release 3 开始支持ef6(

于是决定升级到ef6,在oracle官网中得知,Oracle Data Provider for .NET in ODAC 12c Release 3 开始支持ef6()

安装步骤:

安装步骤:

1.安装odac,下载地址

1.安装odac,下载地址

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

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

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

安装后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>
<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>

注意 entityFramework和 system.data中的版本号,nuget安装后自动生成的一般没问题,我在安装之前把网上找的资料里的配置项放在里面了,但是版本号不一致,程序启动不了,一直没注意到版本号,

注意 entityFramework和 system.data中的版本号,nuget安装后自动生成的一般没问题,我在安装之前把网上找的资料里的配置项放在里面了,但是版本号不一致,程序启动不了,一直没注意到版本号,

找了好一会才发现是这两个地方。

找了好一会才发现是这两个地方。

版权声明:本文由必发88手机在线官网发布于编程,转载请注明出处:步骤及遇到的问题