I am trying to publish a project that uses two DB connection strings and Migration Contexts:
DefaultConnection - Created automatically when starting the project and contains the user tables
AmscanContext - Generated when creating the Entity Model using Code First from an Existing database
I enabled and added two migrations for each one using a different folders and updated the databases (commenting out the create tables for the database I imported)
All works well locally and I have even added some authentication and canEdit rules to the controllers.
I have set up the connection strings to create two new databases and mentioned in the comment below. Here is the configuration.cs for each migration.
This is the App data:
namespace AMScan.Migrations.AmscanContext
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<AMScan.Models.AmscanContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
MigrationsDirectory = @"Migrations\AmscanContext";
}
protected override void Seed(AMScan.Models.AmscanContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
}
}
}
This is the User data:
namespace AMScan.Migrations.ApplicationDbContext
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<AMScan.Models.ApplicationDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
MigrationsDirectory = @"Migrations\ApplicationDbContext";
}
protected override void Seed(AMScan.Models.ApplicationDbContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
}
}
}
Not sure if this tells you much. If there are any specific files you would like me to post please let me know.