I have the following code:
public DataInitializer() {
Database.SetInitializer<DataContext>(null);
try {
using (var context = new DataContext()) {
if (!context.Database.Exists())
{
((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
}
}
}
catch (Exception ex) {
throw new InvalidOperationException("The Data database could not be initialized", ex);
}
}
and
public class DataContext : DbContext
{
public DataContext() : base("xxdata") { }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
public DbSet<Application> Applications { get; set; }
}
The code gets executed when I step through it but it seems like no database file is created (SQL Server Express).
Is there something obvious that I am doing wrong?