I\'m developing an ASP.NET MVC 4 application using VS 2010 and EF 4.3. It retrieves some data from an external database and all worked as expected until I tried to recompile
Found an answer for my question. Thanks all for replies.
Database.SetInitializer<MyContext<Label>>(null);
This fixes the problem and disables DB changes tracking in EF.
Actually there is CreatedOn column in __MigrationHistory table so the problem might be something EF migrations related. If there are no codechanges,pending migrations or anything the error is indeed a very strange case.
PS. I found this, it might prove helpful: http://bstechnical.blogspot.fi/2012/08/invalid-column-name-createdon-code-first.html
In my case it was the MiniProfiler. I use EF 5.0, it uses EF 4.x. After disabling the profiler, the exception was not thrown any more
EF 4.3.1 added a CreatedOn
column to the __MigrationHistory
table, which EF 5.0 subsequently removed. I suspect you have upgraded EF to 4.3.1 since you last updated the database.
You could either run a Migration to add the CreatedOn
column, manually add it yourself, or upgrade to EF 5.0 where it is no longer necessary.