在Visual Studio 2012 RC中看不到.NET的Oracle数据提供程序 [英] Cannot see Oracle Data Provider for .NET in Visual Studio 2012 RC

查看:127
本文介绍了在Visual Studio 2012 RC中看不到.NET的Oracle数据提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Web应用程序移植到Entity Framework 4.5.我的主要目标是同时支持MSSQL和Oracle数据库,并能够通过编程(在Global.asax中)告诉ORM哪个数据源为目标. SQL和Oracle模式显然在功能上是相同的.这是我们已经在生产中使用的一种方法,我们希望将其与另一个ORM一起丢弃.

I am porting a web application to Entity Framework 4.5. My main goal is to support both MSSQL and Oracle databases and be able to tell the ORM which data source to target programmatically (in the Global.asax). The SQL and Oracle schemas are obviously functionally identical; this is an approach we already use in production with another ORM we want to throw away.

注意:我们正在对其进行测试的计算机具有Windows 8 Release Preview Build 8400 64位,Visual Studio Professional 2012 RC 11.0.50706.0和.NET Framework 4.5.50501.它不是标准的开发机器(其他机器具有XP和7,带有Visual Studio 2010和.NET 4),但是我们正在使用一种新的机器来测试这些新技术.我不知道这些新技术是否有问题,还没有在标准"开发机上进行过测试.

NOTE: The machine we are testing it on has Windows 8 Release Preview Build 8400 64 bit, Visual Studio Professional 2012 RC 11.0.50706.0 and .NET framework 4.5.50501. It is not a standard development machine (the others have XP and 7 w/Visual Studio 2010 and .NET 4), but a new one we are using to test these new technologies. I have no idea if any of this new technologies may be the problem, haven't tested it on a "standard" dev machine yet.

简短版本

我将在下面详细说明情况,但主要问题是:

I'll explain the situation in detail right below, but the main questions are:

  1. 在添加新的ADO.NET实体数据模型"向导中,我看不到已安装的ODP.NET数据提供程序(请参见下文),因此无法从Oracle数据库创建模型.为什么?此外,在关于Visual Studio"弹出窗口中,我没有看到列出的适用于Visual Studio的Oracle开发人员工具.我担心Oracle开发人员工具无法正常工作,但是Oracle Universal Installer表示一切都已正确安装(并且我重新引导了几次).
  2. 达到此要求的最佳实践是什么?

长版

首先,我们从SQL Server数据库创建了实体数据模型.到目前为止一切顺利.

First, we created the Entity Data Model from a SQL Server database. So far so good.

然后,我们从我已经设法通过以下方式初始化我们的模型SIAEntities(继承自ObjectContext):

I have managed to initialize our model, SIAEntities (which inherites from ObjectContext), with:

            System.Data.EntityClient.EntityConnectionStringBuilder builder = new System.Data.EntityClient.EntityConnectionStringBuilder();
        builder.Metadata = "res://*/SIA.Models.SIAModelOracle.ssdl|res://*/Models.SIAModel.csdl|res://*/Models.SIAModel.msl";
        builder.ProviderConnectionString = "data source=***;persist security info=True;user id=***;password=***";
        builder.Provider = "Oracle.DataAccess.Client"; 
        SIAEntities db2 = new SIAEntities(builder.ConnectionString);

其中,SIA.Models.SIAModelOracle.ssdl是自定义的书面文件(嵌入式资源),它覆盖.edmx的SSDL部分,并进行了以下修改:

where SIA.Models.SIAModelOracle.ssdl is a custom written file (embedded resource) which overrides the SSDL part of the .edmx and has the following modifications:

    Schema节点的
  1. Provider属性设置为Oracle.DataAccess.Client
  2. 所有数据类型名称均已转换为其等效的Oracle(日期时间>日期,nvarchar> varchar2,图像> blob等)
  3. web.config中添加的oracle.dataaccess.client节点,将bool映射到number(1,0),将tinyint映射到number(3,0)
  1. Provider attribute of the root Schema node set to Oracle.DataAccess.Client
  2. All data type names converted to their Oracle equivalent (datetime > date, nvarchar > varchar2, image > blob, etc)
  3. An oracle.dataaccess.client node added in the web.config which maps bool to number(1,0) and tinyint to number(3,0)

执行第一个查询时出现错误(一个简单的SELECT):我跟踪该错误是由于对数据库执行的查询中的双引号引起的,迫使它区分大小写.

The error arrived when executing the first query (a simple SELECT): I tracked it as being due to the double quotes in the query that gets executed against the db, forcing it to be case-sensitive.

通过手动编辑自定义.ssdl文件并大写所有可以让EF查看"表并逐个识别列的内容,但是我并没有把这个解决方案推得太远(因此在阅读全文之前停止了表),因为a)看起来不太干净b)我很难理解.ssdl和.csdl/.msl部分之间的链接,所以我不确定在哪里大写,在哪里不大写!

By manually editing the custom .ssdl file and uppercasing everything I can let EF "see" the table and recognize a column after the other, but I didn't push this solution too far (thus stopping before getting to read the whole table) because a) it didn't seem too clean b) I have difficulties understanding the links between the .ssdl and the .csdl/.msl parts so I wasn't sure where to uppercase and where not to!

我正在考虑避免该手动工作的另一种策略可能是尝试从Oracle模式中生成一个单独的模型,并用另一个处理两个ObjectContext的类来包装这两个ObjectContext,但这是一个问题# 2说,我不能那样做.

Another strategy I was contemplating to avoid this manual work could be to try and generate a separate model from the Oracle schema and wrap the two ObjectContexts with another class that handles the choice between either of them, but as question #2 says, I cannot do that.

推荐答案

Oracle现在已经发布了适用于Visual Studio 2012和.NET 4.5的适用于Visual Studio的Oracle开发人员工具版本(11.2.0.3.20).您需要这些工具的此版本(或更高版本)才能获得Visual Studio 2012实体设计器支持和其他Visual Studio 2012集成.在这里获取:

Oracle has now released a version (11.2.0.3.20) of Oracle Developer Tools for Visual Studio that works with Visual Studio 2012 and .NET 4.5. You'll need this version (or higher) of these tools for Visual Studio 2012 Entity Designer support and other Visual Studio 2012 integration. Get it here:

http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

从版本12.1.0.1.2开始支持Visual Studio 2013

Edit #2: Visual Studio 2013 is supported beginning with version 12.1.0.1.2

仅供参考-我制作了一个视频,重点介绍了这些工具的其他一些功能:

FYI - I created a video to highlight some of the other features of these tools:

http://www.youtube.com/watch?v=68tlel4iJdM

克里斯蒂安·谢伊

Oracle

这篇关于在Visual Studio 2012 RC中看不到.NET的Oracle数据提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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