ASP .NET MVC 6 Oracle连接字符串

时间:2016-03-16 11:12:26

标签: asp.net-mvc oracle

MVC 6中Oracle连接字符串的正确格式是什么?

我的依赖项:

    private void SearchBar_OnTextChanged (string filter)
    {
        lvListaCompraDef.BeginRefresh();
            lvListaCompraDef.ItemsSource = productsToBuy
                .Where (x => x.Name.ToLower ()
                    .Contains (filter.ToLower ()));
        lvListaCompraDef.EndRefresh();
    }

我的连接字符串:

"EntityFramework": "5.0.0",
"Oracle.ManagedDataAccess": "12.1.2400",
"Oracle.ManagedDataAccess.EntityFramework": "12.1.2400",

报告错误:

{

  "Data": {
    "DefaultConnection": {
      "ConnectionString": "Data Source=myHost:myPort/mydb;User Id=myUser;Password=myPassword"      
    }
  }
}

在MVC 5中我使用:

{"An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."}

1 个答案:

答案 0 :(得分:0)

在您的示例中,您使用托管驱动程序作为数据提供程序来使用oracle DB。  但是在您的EF连接字符串中,您应该使用(providerName =“Oracle.ManagedDataAccess.Client”)

请参阅以下正确的连接字符串:

<add name="TestContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=test;Password=testpassword;Data Source=eftest" />

有关详细信息,请参阅以下链接: https://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallEntityConfig.htm#ODPNT8266