oracle 部署和配置 ODP.NET 以在不安装实体框架的情况下工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13721025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:42:18  来源:igfitidea点击:

Deploying and Configuring ODP.NET to work without installation with Entity Framework

oracleentity-frameworkapp-configodp.netdataprovider

提问by Danny Varod

How do you deploy and configure ODP.NET to work without installation with Entity Framework?

如何部署和配置 ODP.NET 以在不安装实体框架的情况下工作?

A. How to deploy and configure Oracle.DataAccess.Client?

A.如何部署和配置Oracle.DataAccess.Client?

B. How to deploy and configure Oracle.ManagedDataAccess.Client?

B.如何部署和配置Oracle.ManagedDataAccess.Client?

C. What do you need to do in order to make builds with EDMXs with Oracle SSDLs work?

C. 您需要做什么才能使用 EDMX 和 Oracle SSDL 进行构建?

D. What do you need to install for designer support?

D. 您需要安装什么才能获得设计师支持?

回答by Danny Varod

This answer summarizes (hopefully) all the steps required, many of which documented in various places online and might save someone hours of Googling.

这个答案总结了(希望如此)所需的所有步骤,其中许多步骤记录在网上的不同地方,可能会节省一些人的谷歌搜索时间。

A. How to deploy and configure Oracle.DataAccess.Client.

A. 如何部署和配置 Oracle.DataAccess.Client。

A.1. Download ODAC112030Xcopy_64bit.zipor ODAC112030Xcopy_32bit.zip.

A.1. 下载ODAC112030Xcopy_64bit.zipODAC112030Xcopy_32bit.zip

A.1.1. Extract the content of the following folders within the zip file into your application/host's bin/setup folder:

A.1.1. 将 zip 文件中以下文件夹的内容解压缩到您的应用程序/主机的 bin/setup 文件夹中:

A.1.1.1. instantclient_11_2

A.1.1.1. Instantclient_11_2

A.1.1.2. odp.net4\bin\

A.1.1.2. odp.net4\bin\

A.1.1.3. odp.net4\odp.net\bin\

A.1.1.3. odp.net4\odp.net\bin\

A.1.1.4. odp.net4\odp.net\PublisherPolicy\4\

A.1.1.4. odp.net4\odp.net\PublisherPolicy\4\

A.2. Add the following section to the beginning of your application's/host's app.config/web.config (if you already have a configSections element, add the section to it:

A2。将以下部分添加到您的应用程序/主机的 app.config/web.config 的开头(如果您已经有一个 configSections 元素,请将该部分添加到其中:

<configSections>
  <section name="oracle.dataaccess.client"
    type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>

A.3. Add the following sections to the end of your application's/host's app.config/web.config:

A.3. 将以下部分添加到应用程序/主机的 app.config/web.config 的末尾:

A.4. From the ODAC112030Xcopy's folder Run:

A.4. 从 ODAC112030Xcopy 的文件夹运行:

configure.bat odp.net4 somename

I recommend using oraclehome112030_32 or oraclehome112030_64 as the "somename" above.

我建议使用 oraclehome112030_32 或 oraclehome112030_64 作为上面的“somename”。

<system.data>
  <DbProviderFactories>
    <!-- Remove in case this is already defined in machine.config -->
    <remove invariant="Oracle.DataAccess.Client" />
    <add name="Oracle Data Provider for .NET"
         invariant="Oracle.DataAccess.Client"
         description="Oracle Data Provider for .NET"
         type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
  </DbProviderFactories>
</system.data>

<oracle.dataaccess.client>
  <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    <add name="byte" value="edmmapping number(3,0)" />
    <add name="int16" value="edmmapping number(5,0)" />
    <add name="int32" value="edmmapping number(10,0)" />
    <add name="int64" value="edmmapping number(19,0)" />
    <add name="int16" value="edmmapping number(38,0)" />
    <add name="int32" value="edmmapping number(38,0)" />
    <add name="int64" value="edmmapping number(38,0)" />
  </settings>
</oracle.dataaccess.client>








B. How to deploy and configure Oracle.ManagedDataAccess.Client.

B. 如何部署和配置 Oracle.ManagedDataAccess.Client。

B.1. Download ODP.NET_Managed_1120350_Beta.zip

B.1. 下载ODP.NET_Managed_1120350_Beta.zip

B.1.1. Extract the following files into your application/host's bin/setup folder.

B.1.1. 将以下文件解压到您的应用程序/主机的 bin/setup 文件夹中。

B.1.1.1. Oracle.ManagedDataAccess.dll

B.1.1.1. Oracle.ManagedDataAccess.dll

B.1.1.2. x64\Oracle.ManagedDataAccessDTC.dll or x86\Oracle.ManagedDataAccessDTC.dll

B.1.1.2. x64\Oracle.ManagedDataAccessDTC.dll 或 x86\Oracle.ManagedDataAccessDTC.dll

B.2. Add the following section to the beginning of your application's/host's app.config/web.config (if you already have a configSections element, add the section to it:

B.2. 将以下部分添加到您的应用程序/主机的 app.config/web.config 的开头(如果您已经有一个 configSections 元素,请将该部分添加到其中:

<configSections>
  <section name="oracle.manageddataaccess.client"
    type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>

B.3. Add the following sections to the end of your application's/host's app.config/web.config:

B.3. 将以下部分添加到应用程序/主机的 app.config/web.config 的末尾:

<system.data>
  <DbProviderFactories>
    <!-- Remove in case this is already defined in machine.config -->
    <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.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  </DbProviderFactories>
</system.data>

<oracle.manageddataaccess.client>
  <version number="*">
    <settings>
      <!-- Set this path if you are using TNS aliases as connection strings (not recommended) -->
      <!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
      <setting name="TNS_ADMIN" value="C:\"/>
    </settings>
    <edmMappings>
      <edmMapping dataType="number">
        <add name="bool" precision="1"/>
        <add name="byte" precision="2" />
        <add name="int16" precision="5" />
      </edmMapping>
    </edmMappings>
  </version>
</oracle.manageddataaccess.client>








C. For building:

C. 对于建筑:

C.1. Add this section to your EDMX's assembly's app.config:

C.1. 将此部分添加到您的 EDMX 程序集的 app.config 中:

(Haven't tried this with Oracle.ManagedDataAccess.Client yet)

(还没有在 Oracle 上尝试过。托管DataAccess.Client 还没有)

<oracle.dataaccess.client>
  <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    <add name="byte" value="edmmapping number(3,0)" />
    <add name="int16" value="edmmapping number(5,0)" />
    <add name="int32" value="edmmapping number(10,0)" />
    <add name="int64" value="edmmapping number(19,0)" />
    <add name="int16" value="edmmapping number(38,0)" />
    <add name="int32" value="edmmapping number(38,0)" />
    <add name="int64" value="edmmapping number(38,0)" />
  </settings>
</oracle.dataaccess.client>

C.2. Add a file named Oracle.xsd to the same assembly with the content:

C.2. 将名为 Oracle.xsd 的文件添加到具有以下内容的同一程序集中:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="odpnetappconfigmappings" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:complexType name="addtype">
    <xs:attribute name="name" type="xs:string" />
    <xs:attribute name="value" type="xs:string" />
  </xs:complexType>

  <xs:complexType name="settingstype">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="add" type="addtype" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="oracledataaccessclienttype">
    <xs:sequence minOccurs="0" maxOccurs="1">
      <xs:element name="settings" type="settingstype" />
    </xs:sequence>
  </xs:complexType>

  <xs:element name="oracle.dataaccess.client" type="oracledataaccessclienttype" />

</xs:schema>

C.3. Add the above XSD to the above app.config's list of Schemas.

C.3. 将上述 XSD 添加到上述 app.config 的架构列表中。

C.4. If you are getting errors for boolean mappings during build even though build is succeeding, add the app.config mappings to Visual Studio's devenv.exe.config.

C.4. 如果您在构建过程中遇到布尔映射错误,即使构建成功,请将 app.config 映射添加到 Visual Studio 的 devenv.exe.config。

C.5. If you want to use Oracle.ManagedDataAccess.Client, either edit data provider attribute in the EDMX manually prior to build (I have not tried this) or edit it prior to creation of Context at run time and load MSSL from edited copy instead of from resource (this seems to work and I also use a similar trick to choose which MSSL to load for different DB providers).

C.5. 如果您想使用 Oracle.ManagedDataAccess.Client,请在构建之前手动编辑 EDMX 中的数据提供程序属性(我还没有尝试过)或在运行时创建上下文之前对其进行编辑并从编辑的副本加载 MSSL,而不是从资源(这似乎有效,我也使用类似的技巧来选择为不同的数据库提供程序加载哪个 MSSL)。








D. For designer support:

D. 设计师支持:

D.1. Download win64_11gR2_client.zipor win32_11gR2_client.zipand install.

D.1. 下载win64_11gR2_client.zipwin32_11gR2_client.zip并安装。

D.1.1. Select "Administrator" as type of installation.

D.1.1. 选择“管理员”作为安装类型。

D.2. download ODTand install.

D.2. 下载ODT并安装。








I tried this (A and B) on a blank machine (VM) with Windows 7 x64.

我在装有 Windows 7 x64 的空白机器 (VM) 上尝试了这个(A 和 B)。

This procedure does not seem to work with x86 version of Oracle.DataAccess.Client on Windows x64.

此过程似乎不适用于 Windows x64 上的 x86 版本的 Oracle.DataAccess.Client。

The procedure does seem to work with the x64 version of Oracle.DataAccess.Client on Windows x64 and with both versions of Oracle.ManagedDataAccess.Client.

该过程似乎适用于 Windows x64 上的 x64 版本的 Oracle.DataAccess.Client 和两个版本的 Oracle.ManagedDataAccess.Client。

回答by Danny Varod

Update:

更新:

Migrating from Oracle.DataAccess.Client to Oracle.ManagedDataAccess.Clientv12.1.0 (12c) the easy way:

从 Oracle.DataAccess.Client 迁移到Oracle.ManagedDataAccess.Clientv12.1.0 (12c) 的简单方法:

Edit: Download link for managed ODAC v12c Release 1.

编辑: 托管 ODAC v12c 第 1 版的下载链接


If you download winx64_12c_client.zipor winnt_12c_client32.zip, extract them and install (full (admin) installation or custom installation with ODP.NET component, client installation doesn't include this component) on a VM, you'll find the folder \odp.net\managedunder the "client" folder.


如果您下载winx64_12c_client.zipwinnt_12c_client32.zip,将它们压缩并在 VM 上安装(完整(管理员)安装或使用 ODP.NET 组件自定义安装,客户端安装不包括此组件),您将在 VM\odp.net\managed下找到该文件夹“客户端”文件夹。

Within this folder you will find common\Oracle.ManagedDataAccess.dll, x86\Oracle.ManagedDataAccessDTC.dlland x64\Oracle.ManagedDataAccessDTC.dll.

在此文件夹中,您将找到common\Oracle.ManagedDataAccess.dll,x86\Oracle.ManagedDataAccessDTC.dllx64\Oracle.ManagedDataAccessDTC.dll

Copy Oracle.ManagedDataAccess.dllinto your bin directory and either copy the correct platform of Oracle.ManagedDataAccessDTC.dllunder your x86/x64 bin directory or, per client, install the correct platform of that specific DLL into the GAC, keeping your bin as AnyCPU.

复制Oracle.ManagedDataAccess.dll到您的 bin 目录中,然后复制Oracle.ManagedDataAccessDTC.dllx86/x64 bin 目录下的正确平台,或者,根据客户端,将该特定 DLL 的正确平台安装到 GAC 中,将您的 bin 保持为 AnyCPU。

The assembly version of the new DLL is 4.121.1.0, the PublicKeyToken seems to be the same (didn't check it, but it worked without me changing it).

新 DLL 的程序集版本是4.121.1.0, PublicKeyToken 似乎是相同的(没有检查它,但它在没有我更改的情况下工作)。

As before, add this section to your app.configconfiguration/configSections (at the beginning of the app.config file):

和以前一样,将此部分添加到您的app.config配置/configSections(在 app.config 文件的开头):

<configuration>
   <configSections>

Section:

部分:

    <section name="oracle.manageddataaccess.client"
        type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

and close with:

并关闭:

</configSections>

Under system.data/DbProviderFactories (after the above):

在 system.data/DbProviderFactories 下(在上述之后):

<system.data>
  <DbProviderFactories>

add:

添加:

    <remove invariant="Oracle.DataAccess.Client" />
    <remove invariant="Oracle.ManagedDataAccess.Client" />

To make sure you don't have any conflicts in your machine.config

确保您的 machine.config 中没有任何冲突

then add:

然后加:

  <add name="ODP.NET, Managed Driver" invariant="Oracle.DataAccess.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" />

and close with:

并关闭:

  </DbProviderFactories>
</system.data>

NoticeI used Oracle.DataAccess.Clientas the invariant instead of the official Oracle.ManagedDataAccess.Client. This is because I do not want to change all my EDMXs and recompile their assemblies to get them to use the new managed client instead of the old unmanaged one.

请注意,我使用了Oracle.DataAccess.Client作为不变量而不是官方的Oracle.ManagedDataAccess.Client. 这是因为我不想更改我所有的 EDMX 并重新编译它们的程序集以让它们使用新的托管客户端而不是旧的非托管客户端。

Then add the following section (after the above) to your app.config

然后将以下部分(在上述之后)添加到您的 app.config

 <oracle.manageddataaccess.client>
    <version number="*">
      <edmMappings>
        <edmMapping dataType="number">
          <add name="bool" precision="1"/>
          <add name="byte" precision="2" />
          <add name="int16" precision="5" />
        </edmMapping>
      </edmMappings>
    </version>
  </oracle.manageddataaccess.client>

This passed my initial testing, haven't tested thoroughly yet though.

这通过了我的初步测试,但尚未彻底测试。