Ejemplo n.º 1
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!optionsBuilder.IsConfigured)
     {
         var dbcontext = DbConnnectString.GetDatabase("Hr");
         optionsBuilder.UseSqlServer(dbcontext);
     }
 }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            //通过code first 建立数据库
            services.AddDbContext <DBModels.Hr.HrContext>(options => options.UseSqlServer(DbConnnectString.GetDatabase("Hr")));
        }