Could anyone offer any advice on whether it is best practice to have a single context or multiple contexts?
For example, should I have a single context as follows:
public class MyContext
: DbContext
{
public DbSet<Company> Companies { get; set; }
public DbSet<Country> Countries { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new CountryConfiguration());
modelBuilder.Configurations.Add(new CompanyConfiguration());
base.OnModelCreating(modelBuilder);
}
}
Or would I be better creating a separate context for Companies and Countries? So ConpanyContext and CountryContext which would both expose a single DbSet property.
It may just be personal choice, but our database is going to consist of 100s of entities. I'd therefore like to get this right to begin with.
Many thanks,
Paul.