C# 在 Visual Studio 2012 RC 中看不到 Oracle Data Provider for .NET
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11544822/
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
Cannot see Oracle Data Provider for .NET in Visual Studio 2012 RC
提问by Piddu
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.
我正在将 Web 应用程序移植到 Entity Framework 4.5。我的主要目标是同时支持 MSSQL 和 Oracle 数据库,并能够以编程方式(在 Global.asax 中)告诉 ORM 以哪个数据源为目标。SQL 和 Oracle 模式在功能上显然是相同的;这是我们已经在生产中使用的一种方法,我们想扔掉另一个 ORM。
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.
注意:我们正在测试它的机器具有 Windows 8 Release Preview Build 8400 64 位、Visual Studio Professional 2012 RC 11.0.50706.0 和 .NET framework 4.5.50501。它不是标准的开发机器(其他有 XP 和 7 w/Visual Studio 2010 和 .NET 4),而是我们用来测试这些新技术的新机器。我不知道是否有任何新技术可能是问题所在,还没有在“标准”开发机器上对其进行测试。
Short version
精简版
I'll explain the situation in detail right below, but the main questions are:
我将在下面详细解释情况,但主要问题是:
- In the "Add new ADO.NET Entity Data Model" wizard, I cannot see the ODP.NET data provider I installed (see below) and thus I cannot create a model from an Oracle database. Why? Furthermore, in the "About Visual Studio" pop-up I don't see listed Oracle Developer Tools for Visual Studio. My fear is that the Oracle Developer Tools aren't working somehow, but the Oracle Universal Installer said everything was correctly installed (and I rebooted several times).
- What is the best practise to achieve this requirement?
- 在“添加新的 ADO.NET 实体数据模型”向导中,我看不到我安装的 ODP.NET 数据提供程序(见下文),因此我无法从 Oracle 数据库创建模型。为什么?此外,在“关于 Visual Studio”弹出窗口中,我没有看到列出的适用于 Visual Studio 的 Oracle 开发人员工具。我担心 Oracle 开发人员工具无法正常工作,但 Oracle 通用安装程序说一切都已正确安装(我重新启动了几次)。
- 实现此要求的最佳实践是什么?
Long version
长版
First, we created the Entity Data Model from a SQL Server database. So far so good.
首先,我们从 SQL Server 数据库创建了实体数据模型。到现在为止还挺好。
Then, we installed ODAC 11.2 Release 4 and Oracle Developer Tools for Visual Studio (11.2.0.3.0) from http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
然后,我们从http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html安装了 ODAC 11.2 Release 4 和 Oracle Developer Tools for Visual Studio (11.2.0.3.0)
I have managed to initialize our model, SIAEntities(which inherites from ObjectContext), with:
我已经设法初始化我们的模型,SIAEntities(它继承自 ObjectContext),使用:
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);
where SIA.Models.SIAModelOracle.ssdlis a custom written file (embedded resource) which overrides the SSDL part of the .edmx and has the following modifications:
其中SIA.Models.SIAModelOracle.ssdl是自定义写入文件(嵌入式资源),它覆盖 .edmx 的 SSDL 部分并进行以下修改:
Providerattribute of the rootSchemanode set toOracle.DataAccess.Client- All data type names converted to their Oracle equivalent (datetime > date, nvarchar > varchar2, image > blob, etc)
- An
oracle.dataaccess.clientnode added in theweb.configwhich mapsbooltonumber(1,0)andtinyinttonumber(3,0)
Provider根节点的属性Schema设置为Oracle.DataAccess.Client- 所有数据类型名称都转换为它们的 Oracle 等效名称(日期时间 > 日期、nvarchar > varchar2、图像 > blob 等)
oracle.dataaccess.client在web.config其中映射bool到number(1,0)和tinyint到的节点中添加的节点number(3,0)
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.
执行第一个查询时出现错误(一个简单的SELECT):我跟踪它是由于查询中的双引号对数据库执行,迫使它区分大小写。
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!
通过手动编辑自定义 .ssdl 文件并将所有内容大写,我可以让 EF“看到”表格并识别一个接一个的列,但我没有将此解决方案推得太远(因此在阅读整个表格之前停止)因为a) 它看起来不太干净 b) 我很难理解 .ssdl 和 .csdl/.msl 部分之间的链接,所以我不确定在哪里大写,哪里不大写!
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 模式生成一个单独的模型,并将这两个ObjectContexts 与另一个处理其中之一之间的选择的类包装在一起,但正如问题 #2 所说,我不能这样做那。
采纳答案by Christian Shay
Edit: 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:
编辑:Oracle 现在发布了适用于 Visual Studio 的 Oracle Developer Tools 版本 (11.2.0.3.20),可与 Visual Studio 2012 和 .NET 4.5 配合使用。您将需要这些工具的此版本(或更高版本)才能获得 Visual Studio 2012 实体设计器支持和其他 Visual Studio 2012 集成。在这里获取:
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
Edit #2: Visual Studio 2013 is supported beginning with version 12.1.0.1.2
编辑 #2:从版本 12.1.0.1.2 开始支持 Visual Studio 2013
FYI - I created a video to highlight some of the other features of these tools:
仅供参考 - 我创建了一个视频来突出这些工具的一些其他功能:
http://www.youtube.com/watch?v=68tlel4iJdM
http://www.youtube.com/watch?v=68trel4iJdM
Christian Shay
克里斯蒂安·谢伊
Oracle
甲骨文
回答by bflow1
Oracle has released ODP.NET with VS2012 and .NET 4.5 support. I don't see much from them in the way of documentation for this release.
Oracle 已经发布了支持 VS2012 和 .NET 4.5 的 ODP.NET。在此版本的文档方式中,我没有从他们那里看到太多内容。

