0

I updated my dbml file after adding a new column to the database table in DEV. Everything works in DEV environment. But when deployed to test and production I get this Invalid Column Name exception. Any suggestions?

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

UPDATE: Added log:

2015-12-01 09:59:04,267 [29] ERROR [BusinessLogic.Managers.EntityManagers.IntegrationManager.Run] An error occured during call of bla bla

Exception message: Invalid column name 'MyNewAddedColumn'.

Stack-trace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean 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, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.Table1.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) at BusinessLogic.Managers.Integration.syncTable[T1,T2](IList1 Table, ITable1 TableToUpdate) at BusinessLogic.Managers.Integration.Execute() at BusinessLogic.Managers.EntityManagers.IntegrationManager.execute()

Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
bahramzy
  • 133
  • 3
  • 14

1 Answers1

0

It's look like you have not moved your database changes from your local database or lower environment database to production database. Please verify.

So when you run your Linq2SQL in dev it is working because new column present in local or dev database. But in production DBML try to retrive the value from new column from Accounts table but it is not present and resulting in above error

Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
  • Hi and thanks for your answer. I have of course added the new field to the relevant database table both in TEST- and PROD environments and I have made sure that the column name is spelled exactly as in DEV. – bahramzy Dec 01 '15 at 11:45
  • are you sure your new column name is 'MyNewAddedColumn'. I have this problem earlier when i want to add only one column but by mistake i added two column in LinqToSQL because for testing i have added additional column in dev DB, then by mistake i moved my code to UAT and start getting error because in UAT that column is not present – Avinash Jain Dec 01 '15 at 12:06
  • Yes I am sure. That's the only column I have added. I removed the column from my database table in DEV. I updated/refreshed the .dbml file and re-deployed my code. Everything worked in all three environments. Then, I re-added the column to my database table in DEV, regenerated the .dbml file and deployed again to all three environments. Still not working in TEST and PROD environments. – bahramzy Dec 01 '15 at 12:31