数据库上下文 DbContext

数据库上下文配置

public class Db:DbContext
    {
        public Db(DbContextOptions 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; }
        
    }

  

转载于:https://www.cnblogs.com/almmm/p/11533159.html

你可能感兴趣的:(数据库)