在DEV中的数据库表中添加了一个新列后,我更新了我的dbml文件。一切都在DEV环境中工作。但是,当部署到测试和生产时,我会得到"无效列名"异常。有什么建议吗?
var CreateUpdateCtx = new MyDataContext(connectionstring);
var Data = vutTable.Accounts.ToList(); //Calling ToList() results in the exception shown below
更新:添加日志:
2015-12-01 09:59:04267[29]错误[BusinessLogic.Managers.EntityManagers.IntegrationManager.Run]调用bla-bla 时发生错误
异常消息:列名"MyNewAddedColumn"无效。
堆栈跟踪:位于System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection,操作
1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource
1完成,Int32超时,任务&任务布尔异步写入)System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior,RunBehavior运行行为,布尔返回流,字符串方法)System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior行为,字符串方法)System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior行为)System.Data.Linq.SqlClient.SqlProvider.Execute(表达式查询,QueryInfo QueryInfo,IObjectReaderFactory工厂,Object[]parentArgs,Object[]userArgs,ICompiledSubQuery[]subQueries,ObjectlastResult)System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(表达式查询,QueryInfo[]queryInfos,IObjectReaderFactory工厂,Object[]userArguments,ICompiledSubQuery[]subQueries)System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(表达式query)的System.Data.Linq.Table1.GetEnumerator() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
1源)BusinessLogic.Managers.IIntegration.syncTable[T1,T2](IList
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 Table, ITable
1 TableToUpdate)位于位于的BusinessLogic.Managers.IIntegration.Execute()BusinessLogic.Managers.EntityManagers.IntegrationManager.execute()
看起来您还没有将数据库更改从本地数据库或较低环境数据库转移到生产数据库。请核实。
所以,当您在dev中运行Linq2SQL时,它正在工作,因为本地或dev数据库中存在新列。但在生产中,DBML试图从Accounts表的新列中检索值,但它不存在,导致出现上述错误