如何更改由于服务器更改而导致的ADO.net数据库

时间:2014-04-16 04:04:53

标签: c# asp.net database ado.net

我正在使用mvc 4 .net进行项目,我们正在使用ADO.net实体数据模型来访问我们的数据库。该项目最初是在与我的计算机不同的计算机上开发的,因此服务器名称不同。因此,我无法访问数据库所以,我尝试更改连接字符串,我把我的服务器名称和我的数据库名称(与其他计算机相同)我更改了Windows识别的识别方法,因为这样我的电脑使用的方法。但是我仍然会遇到错误。是否有某种向导允许我更改ADO.net对象中的数据库?或者唯一的方法是修改连接字符串?

这是我的连接字符串

<add name="SOMEEntities" 
     connectionString="metadata=res://*/Models.SOMEDataModel.csdl|res://*/Models.SOMEDataModel.ssdl|res://*/Models.SOMEDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MY-SOURCE-SERVER;initial catalog=SOME; integrated security=True; MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

这是原来的

<add name="SOMEEntities" 
     connectionString="metadata=res://*/Models.SOMEDataModel.csdl|res://*/Models.SOMEDataModel.ssdl|res://*/Models.SOMEDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=OTHER-DUDE-SERVER;initial catalog=SOME;persist security info=True;user id=SOME;password=SOME;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

例外类型是:

  EntityFramework.SqlServer.dll中的

System.Data.Entity.Core.EntityCommandExecutionException'

堆栈跟踪(一个大的)

  

堆栈跟踪:               在System.Data.SqlClient.SqlConnection.OnError中(SqlException异常,Boolean breakConnection,Action 1 wrapCloseInAction) in System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction)               在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning中(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)               在System.Data.SqlClient.TdsParser.TryRun中(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&amp; dataReady)               在System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()中               在System.Data.SqlClient.SqlDataReader.get_MetaData()中               在System.Data.SqlClient.SqlCommand.FinishExecuteReader中(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)               在System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async,Int32 timeout,Task&amp; task,Boolean asyncWrite,SqlDataReader ds)中               在System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,TaskCompletionSource 1 completion, Int32 timeout, Task& task, Boolean asyncWrite) in System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) in System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) in System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) in System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext 1 c)               在System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func 3操作中,TInterceptionContext interceptionContext,Action 3 executing, Action 3执行)               在System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader中(DbCommand命令,DbCommandInterceptionContext interceptionContext)               在System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)中               在System.Data.Common.DbCommand.ExecuteReader(CommandBehavior行为)中               在System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand,CommandBehavior behavior)

0 个答案:

没有答案