Мой метод Seed()
никогда не вызывается. Он вызывается, когда я делаю Update-Database
из консоли диспетчера пакетов, но никогда не запускаюсь из кода.
Если я удалю свою базу данных, создаются все таблицы (поэтому выполняются мои классы миграции), но мой код Seed() никогда не вызывается.
MVC 4, Entity Frame Work 5 Code First.
Global.asax:
protected void Application_Start()
{
Database.SetInitializer<MyContext>(new DbInitializer());
}
DBInit:
internal class DbInitializer : MigrateDatabaseToLatestVersion<MyContext, Migrations.Configuration>
{
}
DBContext:
public partial class MyContext : DbContext
{
public MyContext() : base("DefaultConnection")
{
}
// public DBSets....
}
Конфигурация:
internal sealed class Configuration : DbMigrationsConfiguration<MyContext>
{
public Configuration()
{
// The constructor is actually called
AutomaticMigrationsEnabled = false;
}
protected override void Seed(MyContext context)
{
// My seed code, never called
}
Что может быть неправильным?