EF6 First code migration from class library results to Blank Up / Down

I am rewriting code from EF5 to EF6. As part of the process, I am trying to break down the database context logic into a class library. This worked before it was part of the main project, but now leads to empty up / down methods at startup add-migration.

public class SLDBContext : DbContext
{
    public SLDBContext()
        : base("name=SLApi")
    {
        System.Data.Entity.Database.SetInitializer(new CreateDatabaseIfNotExists<SLDBContext>());
    }

    public DbSet<Language> Languages { get; set; }
    public DbSet<Template> Templates { get; set; }
    public DbSet<TemplateFolder> TemplateFolders { get; set; }
    public DbSet<Element> Elements { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        //modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
    }
}

Running add-migration MagicWombatwith my class library selected in the package manager console gives me the following:

public partial class MagicWombat : DbMigration
{
    public override void Up()
    {
    }

    public override void Down()
    {
    }
}

My seed methods are empty, but I would expect it to create me some empty tables without regard. Obviously I'm missing something, but what?

+3
source share
1 answer

DbContext , -StartUpProjectName, EF .

add-migration MagicWombat -StartUpProjectName YourProject

PM, :

add-migration MagicWombat -ProjectName YouClassLibrary -StartUpProjectName YourProject
+1

All Articles