使用odp.net管理的驱动程序实现实体框架的功能导入 [英] Function imports for entity framework with odp.net managed driver

查看:187
本文介绍了使用odp.net管理的驱动程序实现实体框架的功能导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从ODP Unmanaged切换到ODP Managed(与实体框架结合)。
在web.config部分中添加必要的信息后,非托管驱动程序正常工作。我可以添加存储过程并使用函数导入 - 获取列信息生成复杂类型(我试图使用OUT refcursor参数导入存储过程)。
切换之后,配置部分被更新以反映新的格式,并且一切都在运行时起作用(因此格式是正确的)。



然而,当我尝试再次生成复杂的类型(或添加一个新的函数导入)我刚刚得到一个 System.notSupportedException消息:此选择器不支持指定的类型)没有任何指示/选择它是(显然)...



Google已经没有任何东西,Oracle论坛上的线程也没有收到回复。



版本:
ODP.Net(ODAC):v12.1(生产版本; DLL v4.121.1.0)
EF v5
.NET v4。 5
配置文件(修剪一下):

 < configSections> 
< section name =oracle.manageddataaccess.clienttype =OracleInternal.Common.ODPMSectionHandler,Oracle.ManagedDataAccess/>
< / configSections>
< oracle.manageddataaccess.client>
< version number =*>
< edmMappings>
< edmMapping dataType =number>
< add name =boolprecision =1/>
< add name =byteprecision =2/>
< add name =int16precision =5/>
< add name =int32precision =10/>
< add name =int64precision =38/>
< / edmMapping>
< / edmMappings>
< implicitRefCursor>
< storedProcedure schema =ECOMname =SHP_API_ORDERS.CREATE_ORDER>
< refCursor name =O_RS>
< bindInfo mode =Output/>
< metadata columnOrdinal =0columnName =COL1nativeDataType =NumberproviderType =DecimalallowDBNull =falsenumericPrecision =10numericScale =0/>
< metadata columnOrdinal =1columnName =COL2nativeDataType =DateproviderType =DateallowDBNull =true/>
< metadata columnOrdinal =2columnName =COL3nativeDataType =Varchar2providerType =Varchar2allowDBNull =falsecolumnSize =10/>
< / refCursor>
< / storedProcedure>
< / implicitRefCursor>
< / version>
< / oracle.manageddataaccess.client>
< entityFramework>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework/>
< / entityFramework>
< system.data>
< DbProviderFactories>
< remove invariant =Oracle.ManagedDataAccess.Client/>
< add name =ODP.NET,被管理的驱动程序
invariant =Oracle.ManagedDataAccess.Client
description =用于.NET的托管驱动程序的Oracle数据提供程序
type =Oracle.ManagedDataAccess.Client.OracleClientFactory,Oracle.ManagedDataAccess,Version = 4.121.1.0,Culture = neutral,PublicKeyToken = 89b483f429c47342/>
< / DbProviderFactories>
< /system.data>


解决方案

隐藏的ref cursor配置文件格式在Unmanaged ODP.NET和托管ODP.NET。这可能是你的问题的一部分。为了节省您的头发,请安装最新的Visual Studio(Oracle)开发工具,并使用自动生成此配置的新功能:

>

1)如果尚未安装ODT 12.1

2)在服务器资源管理器中查找存储过程,右键单击3)对于表示实体函数返回值的输出参考光标,选择添加到配置复选框。



4)然后选择显示配置(然后剪切并粘贴)或添加到配置。



以下是我正在谈论的截图:



http://i.imgur.com/t1BfmUP.gif



如果这不能解决问题,玩这个布尔值映射。我不是100%肯定这个写作,但我记得听到支持布尔是管理和非托管ODP.NET之间的另一个区别。我确定它被埋在发行说明或文档的某个地方。



Christian Shay



Oracle


I recently switched from ODP Unmanaged to ODP Managed (in conjunction with Entity Framework). The Unmanaged drivers were working fine after adding the necessary information in the web.config section. I could add the stored procedures and generate the complex types using the Function Import - Get Column information (I'm trying to import a stored procedure with an OUT refcursor parameter). After the switch the config section was updated to reflect the new format and everything works at runtime (so the format is correct).

However when I try to generate the complex types again (or add a new Function Import) I just get a System.notSupportedException Message: The specified type is not supported by this selector) Without any indication which type/selector it is (obviously)...

Google has turned up nothing and the thread on the Oracle Forums has gathered no response as well.

Versions: ODP.Net (ODAC) : v12.1 (Production release; DLL v4.121.1.0) EF v5 .NET v4.5 Config file (trimmed a bit):

<configSections>
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
</configSections>
<oracle.manageddataaccess.client>
    <version number="*">
        <edmMappings>
            <edmMapping dataType="number">
                <add name="bool" precision="1"/>
                <add name="byte" precision="2" />
                <add name="int16" precision="5" />
                <add name="int32" precision="10" />
                <add name="int64" precision="38" />
            </edmMapping>
        </edmMappings>
        <implicitRefCursor>
            <storedProcedure schema="ECOM" name="SHP_API_ORDERS.CREATE_ORDER">
                <refCursor name="O_RS">
                    <bindInfo mode="Output"/>
                    <metadata columnOrdinal="0" columnName="COL1" nativeDataType="Number" providerType="Decimal" allowDBNull="false" numericPrecision="10" numericScale="0" />
                    <metadata columnOrdinal="1" columnName="COL2" nativeDataType="Date" providerType="Date" allowDBNull="true" />
                    <metadata columnOrdinal="2" columnName="COL3" nativeDataType="Varchar2" providerType="Varchar2" allowDBNull="false" columnSize="10" />
                </refCursor>
            </storedProcedure>
        </implicitRefCursor>
    </version>
</oracle.manageddataaccess.client>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</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.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
</system.data>

解决方案

The implicit ref cursor config file format is different between Unmanaged ODP.NET and Managed ODP.NET. That might be part of your problem.

To save yourself from pulling your hair out, install the latest Oracle Developer Tools for Visual Studio (ODT) and use the new feature that automatically generates this config:

1) Install ODT 12.1 if you haven't already

2) Find the stored procedure in server explorer, right click it and run it, and enter input parameters.

3) For the output ref cursor that represents the return value for your Entity Function, choose "Add to Config" checkbox.

4) Then select either "Show Config" (and then cut and paste) or "Add to Config".

Here is a screenshot of what I am talking about:

http://i.imgur.com/t1BfmUP.gif

If this doesn't fix the problem, play around with that boolean mapping. I am not 100% sure of this as of this writing, but I remember hearing that support for booleans is another difference between managed and unmanaged ODP.NET. I'm sure it's buried in the release notes or doc somewhere.

Christian Shay

Oracle

这篇关于使用odp.net管理的驱动程序实现实体框架的功能导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆