Draco
Draco

Reputation: 16364

SQL Server 2014 MARS error when using Entity Framework

I've altered one of my tables in the DB by adding two additional columns:

DeletedBy NVARCHAR(100)
DeletedOn DATETIME

The problem is that when I now either try adding or updating a row in the table I get the following error:

Procedure []: Error occured (207): Invalid column name 'DeletedBy'.\r\nA transaction that was started in a MARS batch is still active at the end of the batch. The transaction is rolled back.

Dropping the columns from the DB fixes the issue. Any idea what may be causing this error? No other changes have been made other than adding the columns to the table.

I'm using EF 6

Upvotes: 0

Views: 1165

Answers (2)

Luca Ghersi
Luca Ghersi

Reputation: 3321

There are at least a couple of things you can try.

  • Disable MARS and try again: are you getting any error? Transaction rollback can mask the actual error. As I can see, the "DeletedBy" field is not nullable and looks like a strange thing: what are you going to write in that field when you are creating the record?
  • Check MARS, Transactions and SQL Error 3997, 3988 or 3983 by Cihan Biyikoglu.

Upvotes: 1

Draco
Draco

Reputation: 16364

So after pulling out all of my hair I found out that the issue was actually caused by a trigger on the table I was updating. Disable the trigger and all is good. But none-the-less the error was quite cryptic.

Upvotes: 0

Related Questions