"Invalid column name 'CreatedOn'" - Entity Framework Code First

by Victor 7. September 2012 16:53

I started getting this error in a production system a day ago but nothing had changed in that application. The application is a REST web service and hasn't been touched in months. BUT, I did deploy a different application that uses the same database. The new application uses Entity Framework 5.0 and the existing application uses 4.3. Also, the new application uses Code First Migrations so a new table called __MigrationHistory was automatically added. It turns out that the existing application had automatic migration enabled. So, all I had to do was turn that off using this line of code and redeploy the dll.

 

Database.SetInitializer<MyModelContext>(null);
 
I don't think automatic migrations should be enabled by default but I suppose some people would want it. Sometimes I think MS tries to put too many "automagic" features in their frameworks...

Tags: , ,

Entity Framework | Software Development | Web Development

                 

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Powered by BlogEngine.NET 2.5.0.6

About Us

Wuji Touch is a software consulting firm based in Delray Beach, Florida. We specialize in Microsoft technologies, but we also have experience with Progress OpenEdge, iOS, and Android development. This is our blog. These are the tales of the pains and pleasures we experience daily in our journey through 1s and 0s.

Month List