0

在 DEV 的数据库表中添加新列后,我更新了我的 dbml 文件。一切都在 DEV 环境中工作。但是当部署到测试和生产时,我得到了这个 Invalid Column Name 异常。有什么建议么?

var CreateUpdateCtx = new MyDataContext(connectionstring);
var Data = vutTable.Accounts.ToList(); //Calling ToList() results in the exception shown below

更新:添加日志:

2015-12-01 09:59:04,267 [29] 错误 [BusinessLogic.Managers.EntityManagers.IntegrationManager.Run] 调用 bla bla 期间发生错误

异常消息:列名“MyNewAddedColumn”无效。

堆栈跟踪:在 System.Data.SqlClient.SqlConnection.OnError(SqlException 异常,布尔 breakConnection,Action1 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, TaskCompletionSourceSystem.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String方法)在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior 行为)在 System.Data.Linq.SqlClient.SqlProvider.Execute(表达式查询,QueryInfo queryInfo,IObjectReaderFactory 工厂,Object[] parentArgs,Object[] userArgs,ICompiledSubQuery[ ] subQueries, Object lastResult) 在 System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) 在 System.Data.Linq.SqlClient。System.Data.Linq.Table 处的 SqlProvider.System.Data.Linq.Provider.IProvider.Execute(表达式查询)1.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable 1 source) at BusinessLogic.Managers.Integration.syncTable[T1,T2](IList 1 TableToUpdate) at BusinessLogic.Managers.Integration.Execute() at BusinessLogic.Managers.EntityManagers.IntegrationManager.execute()1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 Table, ITable

4

1 回答 1

0

看起来您还没有将数据库更改从本地数据库或较低环境数据库移动到生产数据库。请核实。

因此,当您在 dev 中运行 Linq2SQL 时,它正在工作,因为本地或 dev 数据库中存在新列。但在生产 DBML 尝试从 Accounts 表的新列中检索值但它不存在并导致上述错误

于 2015-12-01T11:33:14.740 回答