Reputation: 197
In my previous project I had two DbContexts:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
public class BlogContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
}
And I had no problem creating and migrating my database. Today I created a new project that has only two contexts too and I can not migrate the database and stackoverflow suggests to make separate migrations, store them in separate folders, etc. What did I do wrong that I can migrate two contexts with one simple command?
Upvotes: 1
Views: 40
Reputation: 596
You would require two separate connections for that in web.config. Each for one respective dbcontext. Two dbContexts cannot share a connection.
Upvotes: 1