数据库上下文 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; }
        
    }

  

posted @ 2019-09-17 13:35  阿拉木木  阅读(2788)  评论(1编辑  收藏  举报