I have an ASP.NET MVC 4 project with Entity Framework 5, .NET 4.5 and Visual Studio 2012. In my solution I've put all the models in a project called Model, all the Repositories and my DbContext in one more project called Data. I activate the migrations in the Data project with the Enable-Migrations command. I decide to handle them manually. If I create a new migration with the Add-Migration command everything works very well. If, for example, I add a new column to a table, it works fine. I can see the new column in the database schema and I see the new record into the _MigrationHistory table. At this point, with the new column created, I need to add this column to the right model. So, i add this method to my code-first model class and I run the project. It delete my database, and init it with the initial migration. I can't tweak a model without loosing all data. How I can avoid this behavior? Thanks
UPDATE:
Configuration.cs
namespace NegoziazioneEventi.Data.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<NegoziazioneEventi.Data.NeDataContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(NegoziazioneEventi.Data.NeDataContext context)
{
}
}
}
Application_Start() in Global.asax
protected void Application_Start()
{
// init basic data on database
System.Data.Entity.Database.SetInitializer(new Models.InitData());
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
_container = Bootstrapper.GetWindsorContainer();
}