Abp添加DBContext

var controlSchedulesRepository = Abp.Dependency.IocManager.Instance.Resolve<Configuration.IAppConfigurationAccessor>();
                            var optionsBuilder = new DbContextOptionsBuilder<EvaluationSystemDbContext>();

                            optionsBuilder.UseSqlServer(controlSchedulesRepository.Configuration["ConnectionStrings:Default"]);
                            using (var context = new EvaluationSystemDbContext(optionsBuilder.Options))
                            {
                                var old = context.SchoolTerm.Where(x => x.Id == input.oldTermId&&x.TenantId==1&&x.IsDeleted==false).FirstOrDefault();
                            }
posted @ 2021-09-06 09:02  cv玲玲  阅读(288)  评论(0编辑  收藏  举报