I recently watched the Domain-Driven Design Fundamentals on Pluralsight by Steve Smith and Julie Lerman, it was a great course, but do I have a question relating to EF Code-First and DDD, I get the concept of rich entities and actually understand most of DDD but I am struggling to understand the use of EF Code-First within DDD. Lets say I have two bounded contexts and I have a Customer entity in each of the bounded contexts sharing an Id and Name.
namespace Accounts
{
public class Customer : Entity
{
public Guid Id { get; private set; }
public string Name { get; private set; }
public string AccountNo { get; private set; }
}
}
namespace Deliveries
{
public class Customer : Entity
{
public Guid Id { get; private set; }
public string Name { get; private set; }
public Address DeliveryAddress { get; private set; }
}
}
In each bounded context I have a data layer with a DbContext, lets for the sake of argument call one Accounts.AccountsDbContext and Deliveries.DeliveriesDbContext (each has a IDbSet, which uses its own bounded context Customer entity as defined above)
My question and what I am struggling to understand is how does one handles code-first migrations across the different DbContext's. The Customer entites refer to the same database table but expose only those properties that are relevant to the bounded context they are in. So how does EF handle this through migrations?