简体   繁体   English

实体框架Oracle连接字符串

[英]Entity Framework Oracle Connection String

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. 首先介绍一下:我用XE版本的Oracle设置了另一台PC。 This PC is connected to a hub, which my PC is connected to as well. 此PC连接到集线器,我的PC也连接到集线器。 I also added this PC to my computers tnsnames.ora file for Oracle and it the entry looks like this... 我还将这台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. 然后,我使用TNS和我添加的tnsnames条目,从现有数据库进入visual studio 2010和Generated a Model(.edmx),它工作正常。 The connection string was generated in the app.config file for the project and it looks like this. 连接字符串是在项目的app.config文件中生成的,它看起来像这样。

<add name="Test_Entities" connectionString="metadata=res://*/TestDatabase.csdl|res://*/TestDatabase.ssdl|res://*/TestDatabase.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string=&quot;DATA SOURCE=EF1DEV.TEST.SERVER;PASSWORD=hr;USER ID=HR&quot;" 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? 有什么想法会出错吗?

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. 您可能希望查看位于使用适用于Visual Studio的Oracle Developer Tools构建.NET应用程序的教程,该教程将指导您完成所需的步骤。

Basically the steps are: 基本上步骤是:

  • Download and install ODAC. 下载并安装ODAC。
  • Add Oracle.DataAccess and Oracle.ManagedDataAccess references to your project 将Oracle.DataAccess和Oracle.ManagedDataAccess引用添加到项目中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM