Inspired by [@JulieLerman 's DDD MSDN Mag Article 2013][1]
public class ShippingContext : BaseContext
{
public DbSet Shipments { get; set; }
public DbSet Shippers { get; set; }
public DbSet Order { get; set; } //Orders table
public DbSet ItemsToBeShipped { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Ignore();
modelBuilder.Ignore();
modelBuilder.Configurations.Add(new ShippingAddressMap());
}
}
public class BaseContext
DbContext where TContext : DbContext
{
static BaseContext()
{
Database.SetInitializer(null);
}
protected BaseContext() : base("DPSalesDatabase")
{}
}
"If you’re doing new development and you want to let Code First create or migrate your database based on your classes, you’ll need to create an “uber-model” using a DbContext that includes all of the classes and relationships needed to build a complete model that represents the database. However, this context must not inherit from BaseContext." JL