如何在 VS2017 中为实体框架添加 Oracle 提供程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45950351/
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
How to add Oracle provider in VS2017 for Entity Framework?
提问by Hyman3694078
I want to connect to a database(Oracle 12c) for generating ADO.NET model, Code First From Database. I have installed ODAC for VSbut there is still no option for connecting Oracle DB at the Entity Data Model Wizard:
我想连接到数据库(Oracle 12c)以生成 ADO.NET 模型,Code First From Database。我已经为 VS安装了ODAC,但在实体数据模型向导中仍然没有连接 Oracle DB 的选项:
At Server Explorer there is a Oracle provider but it is stated as deprecated:
在服务器资源管理器中有一个 Oracle 提供程序,但它被声明为已弃用:
I've also tried to install the following 4 Nuget packages but still no Oracle provider at Entity Data Model Wizard:
我还尝试安装以下 4 个 Nuget 包,但在实体数据模型向导中仍然没有 Oracle 提供程序:
I'm suspecting VS2017(Community) is not looking at where I installed ODAC for the list of providers it use but I can't figure where it store this configuration.
我怀疑 VS2017(Community) 没有查看我安装 ODAC 的位置以获取它使用的提供程序列表,但我无法确定它存储此配置的位置。
Is there anything I'm missing? Or is there other ways to use EF for Oracle? E.g. Fallback to VS2015, create entity models manually (how do I do that?), etc.
有什么我想念的吗?或者还有其他方法可以将EF用于Oracle吗?例如回退到 VS2015,手动创建实体模型(我该怎么做?)等。
Please help me I don't want to write plain SQL in code ever again! Thanks.
请帮助我,我不想再在代码中编写纯 SQL!谢谢。
采纳答案by Hong Van Vit
I have the same error. I solve this problem by add Oracle database from Visual 2015. And then Open project by Visual 2017. It done. I has been read a lot of topic about this. They say now, Oracle not yet Support for connecting Oracle DB at the Entity Data Model Wizard you can see at here: https://community.oracle.com/thread/4024914
我有同样的错误。我通过从 Visual 2015 添加 Oracle 数据库解决了这个问题。然后通过 Visual 2017 打开项目。完成了。我已经阅读了很多关于这个的话题。他们现在说,Oracle 尚不支持在实体数据模型向导中连接 Oracle DB,您可以在这里看到:https: //community.oracle.com/thread/4024914
回答by Joaquim Raurell.Xerox
There is something extra:
还有一些额外的东西:
- Nuget package manager suggests Oracle.ManagedDataAccess.EntityFramework 18.3.0
- Nuget 包管理器建议使用 Oracle.ManagedDataAccess.EntityFramework 18.3.0
This won't work with the latest ODP. Nuget Package versions should match ODP versions:
这不适用于最新的 ODP。Nuget 包版本应与 ODP 版本匹配:
- ODP 12.2.0.1.1
- Nuget Oracle.ManagedDataAccess.EntityFramework 12.2.1100
- ODP 12.2.0.1.1
- Nuget Oracle.ManagedDataAccess.EntityFramework 12.2.1100
If not the Entity Data Model Wizard will crash without leaving any trace in the
如果不是,实体数据模型向导将崩溃而不在
C:\Users\YOURUSER\AppData\Roaming\Microsoft\VisualStudio
C:\Users\YOURUSER\AppData\Roaming\Microsoft\VisualStudio
回答by kmxr
I solved this by installing Oracle Developer Tools for Visual Studio 2017
我通过安装Oracle Developer Tools for Visual Studio 2017解决了这个问题
回答by monir hossain
I was facing same problem. first ensure that you installed odac for visual studio 2017 just go this link and follow: https://www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownloadvs2017-3806459.htmluninstall previous odac version. Hopefully, if you install from the link, you will get all things.
我面临同样的问题。首先确保您为 Visual Studio 2017 安装了 odac 只需转到此链接并遵循:https: //www.oracle.com/technetwork/topics/dotnet/downloads/odacmsidownloadvs2017-3806459.html 卸载以前的 odac 版本。希望如果你从链接安装,你会得到所有的东西。
回答by Par Douhan
I hade the sam problem, but found the solution here:
我遇到了同样的问题,但在这里找到了解决方案:
Do not use the .NET driver. Use the ODP.NET driver (managed or unmanaged).
不要使用 .NET 驱动程序。使用 ODP.NET 驱动程序(托管或非托管)。
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/vs2012welcome-1835382.html
http://www.oracle.com/technetwork/topics/dotnet/whatsnew/vs2012welcome-1835382.html
Create a new connection from Server Explorer in Visual Studio and use these images as guides: change the datasource, making sure to choose the flavor of ODP.NET that your .NET application will use (Managed or Unmanaged) - and then connect to oracle. In the Oracle connection dialog, if you have a connection alias choose a "Connection Type" of "TNS" and then choose the alias from the "Data Source Name" drop down list. If you do not have a connection alias, you can choose a Connection Type of "EZ Connect" and then provide the host, port, and service name for the database you wish to connect to.
从 Visual Studio 中的服务器资源管理器创建一个新连接并使用这些图像作为指南:更改数据源,确保选择您的 .NET 应用程序将使用的 ODP.NET 风格(托管或非托管) - 然后连接到 oracle。在 Oracle 连接对话框中,如果您有连接别名,请选择“TNS”的“连接类型”,然后从“数据源名称”下拉列表中选择别名。如果您没有连接别名,您可以选择“EZ Connect”的连接类型,然后为要连接的数据库提供主机、端口和服务名称。
Best Regards, Par
最好的问候,帕