实体框架 Oracle 连接字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22919893/
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
Entity Framework Oracle Connection String
提问by merp
I need help with this connection string I am using. First a little background: I set up another PC with the XE version of Oracle. This PC is connected to a hub, which my PC is connected to as well. I also added this PC to my computers tnsnames.ora file for Oracle and it the entry looks like this...
我需要有关我正在使用的连接字符串的帮助。首先是一点背景知识:我用 XE 版的 Oracle 设置了另一台 PC。这台 PC 连接到集线器,我的 PC 也连接到集线器。我还将这台 PC 添加到我的计算机 tnsnames.ora 文件中用于 Oracle,它的条目看起来像这样......
EF1DEV.TEST.SERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = testcomputername.my.test.dom)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xe)
)
)
I then went into visual studio 2010 and Generated a Model (.edmx) from an existing database using TNS and the tnsnames entry I added, and it worked fine. The connection string was generated in the app.config file for the project and it looks like this.
然后我进入 Visual Studio 2010 并使用 TNS 和我添加的 tnsnames 条目从现有数据库生成模型 (.edmx),它运行良好。连接字符串是在项目的 app.config 文件中生成的,它看起来像这样。
<add name="Test_Entities" connectionString="metadata=res://*/TestDatabase.csdl|res://*/TestDatabase.ssdl|res://*/TestDatabase.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="DATA SOURCE=EF1DEV.TEST.SERVER;PASSWORD=hr;USER ID=HR"" providerName="System.Data.EntityClient" />
The issue is when I try to actually use my model in code. Like This:
问题是当我尝试在代码中实际使用我的模型时。像这样:
using(Test_Entities testEnt = new Test_Entities())
{
}
I get an exception that says [System.ArgumentException] = "The specified store provider cannot be found in the configuration, or is not valid."
我收到一个异常,内容为 [System.ArgumentException] =“在配置中找不到指定的存储提供程序,或者无效。”
And the inner exception says InnerException = "Unable to find the requested .Net Framework Data Provider. It may not be installed."
内部异常表示 InnerException = “无法找到请求的 .Net Framework 数据提供程序。它可能未安装。”
Any thoughts as to whats going wrong?
关于出了什么问题的任何想法?
回答by Robert H
In order to use Oracle as a provider you need to download and add the oracle ODAC package
为了使用 Oracle 作为提供程序,您需要下载并添加oracle ODAC 包
You may want to review the tutorials located at Building .NET Applications Using Oracle Developer Tools for Visual Studio which will walk you through the required steps.
您可能需要查看使用 Oracle Developer Tools for Visual Studio 构建 .NET 应用程序中的教程,该教程将引导您完成所需的步骤。
Basically the steps are:
基本上步骤是:
- Download and install ODAC.
- Add Oracle.DataAccess and Oracle.ManagedDataAccess references to your project
- 下载并安装 ODAC。
- 将 Oracle.DataAccess 和 Oracle.ManagedDataAccess 引用添加到您的项目