0

I'm using ASP.NET MVC 4, Entity Framework 6, Visual Studio 2013, IIS 7 and SQL Server 2012 Express. I recently made a change to our web app and added 2 columns using code-first migrations. Tested everything and it was working. Published everything to the web server and everything worked fine for about 4 hours and then we started getting invalid column name errors.

I started looking in the database and the 2 columns I added earlier were gone. I re-added the columns by using update-database command from VS2013 and everything was working again.

Where can I go to try and figure out what happened?

2
  • Maybe some restore was made? Commented Jul 31, 2014 at 16:26
  • We are a small company and I'm the only it person. Thanks though. Commented Jul 31, 2014 at 19:39

2 Answers 2

0

Go to Migrations folder change the value of AutomaticMigrationsEnabled in constructor of class Configuration to false

public Configuration()
{
      AutomaticMigrationsEnabled = false;
}
1
  • I changed this and and it worked for a couple hours and then my users started getting this error Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration. You can use the Add-Migration command to write the pending model changes to a code-based migration. Commented Jul 31, 2014 at 19:37
0

I would go into my SQL log to find out what happened. I do not think this had anything to do with Entity or your application. Unless your deployment web config connection string was pointing to your development database during the first 4 hours and then someone changed it to your production server.

1
  • Unfortunately I made the mistake of doing everything on the production database :( Commented Jul 31, 2014 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.