Here is my code (Model);
public class XpsEntity
{
public DbSet<AModel> A { get; set; }
public DbSet<TModel> T { get; set; }
public class SDbContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<XpsEntity>().ToTable("Table1");
modelBuilder.Entity<XpsEntity>().ToTable("Table2");
}
}
Is my coding wrong? Because every time I create a controller using MVC Controller Entity Framework. I always get the "Unsupported context type" error.
DbSet
properties need to be nested in a DbContext
derived class
public class SDbContext : DbContext {
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
modelBuilder.Entity<AModel>().ToTable("Table1");
modelBuilder.Entity<TModel>().ToTable("Table2");
}
public DbSet<AModel> A { get; set; }
public DbSet<TModel> T { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.