数据库上下文 DbContext
数据库上下文配置
public class Db:DbContext { public Db(DbContextOptions<Db> options):base(options) { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=test;User Id=sa;Password=123456",p=>p.UseRowNumberForPaging()); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); } public virtual DbSet<***> *** { get; set; } }