Reputation: 41
I made this change, before it was like this
public DbSet<Pessoa> Pessoas { get; set; }
Now it's this way
class ContextData<T> : DbContext where T : class
{
public DbSet<T> Dbset { get; set; }
public ContextData() : base("name=Connection")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Configurations.Add(new PessoaMapping());
}
}
So now I do not know what I do in class migrations
internal sealed class Configuration : DbMigrationsConfiguration<local.blogapi.Context.ContextData
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(local.blogapi.Context.ContextData context)
{
}
}
I know it's going to make a mistake. I do not know how to get the entities or if there is any specific command at the time of doing the migration, or if I pass some interface, such as IEntity
Upvotes: 0
Views: 332
Reputation: 622
you're probably wrong.
A context is a group of dbset (dbsets represent sql tables), read this.
I think that you don't need one context for every table in your db. Use of more contexts may make sense if you want to separate dbsets that have different logic (based on the schema for example, or to separate read / write tables)
Upvotes: 1