When the developer tries to run the ```PM> Enable-Migrations``` command with a model that throws an exception this puts the project in a confusing state. Migrations are successfully enabled and a model context is created, but the power shell command gives a red error message and a stack trace leading the user to believe that migrations were not successfully enabled.
To repro this issue create a project with the following model and then run the Enable-Migrations command
```
public class EntityContext : DbContext
{
public DbSet<Entity> Entities { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add<ModelBasedConvention>(DataSpace.CSpace);
}
}
public class Entity
{
public int ID { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public DateTime Timestamp { get; set; }
}
class ModelBasedConvention : IModelConvention<EntitySet>
{
public void Apply(EntitySet entity, EdmModel model)
{
entity.Name = "_" + entity.Name;
}
}
```
To repro this issue create a project with the following model and then run the Enable-Migrations command
```
public class EntityContext : DbContext
{
public DbSet<Entity> Entities { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add<ModelBasedConvention>(DataSpace.CSpace);
}
}
public class Entity
{
public int ID { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public DateTime Timestamp { get; set; }
}
class ModelBasedConvention : IModelConvention<EntitySet>
{
public void Apply(EntitySet entity, EdmModel model)
{
entity.Name = "_" + entity.Name;
}
}
```