我有一个使用.NET 4.0和EF6的应用程序--这在Server中运行得很好,现在,我需要以同样的方式使用Oracle。我在这个proyect中有一个有5个表的模型,当我将这个proyect与这个DB迁移连接起来时,在其中添加这个新闻表。
现在,我将所有的引用都放在Oracle上。
Oracle.DataAccess.dll
Oracle.DataAccess.EntityFramework
Oracle.ManagedDataAccess.EntityFramework把这个放进web.config里
<section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>我在用这个康涅狄格字符串
<add name="ChatContext" connectionString="Data Source=serversql; Initial Catalog=database;uid=user;password=pass;" providerName="System.Data.SqlClient"/>现在我在试着
<add name="ChatContext" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracleserver)(PORT=1521))(CONNECT_DATA=SERVICE_NAME=oracledb)));User Id=user;Password=pass;" providerName = "Oracle.ManagedDataAccess.Client"/>我的文档中有一个"ChatContext“DB,并将其删除为Migrations,生成一个新的上下文文件。
当我试图弹出代码时,出现以下错误:
An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file.我生成一个新的MVC proyect来检查conn字符串是否正常,并且可以连接到db,而且它是。
<add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="data source=oracledb;password=pass;persist security info=True;user id=user"" providerName="System.Data.EntityClient" /></connectionStrings>发布于 2015-07-17 14:17:30
我认为您只需要从下面更改连接字符串:
"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracleserver)(PORT=1521))(CONNECT_DATA=SERVICE_NAME=oracledb)));User Id=user;Password=pass;"..。取而代之的是:
"Data Source=oracledb;User Id=user;Password=pass;"只需将Data Source设置为服务名称即可。
https://stackoverflow.com/questions/31476829
复制相似问题