在DbContext.OnConfiguring和AspCore Startup.ConfigureServices中都定义了optionsBuilder时,预期的结果是什么? [英] What are expected results when optionsBuilder is defined in both DbContext.OnConfiguring and AspCore Startup.ConfigureServices?
本文介绍了在DbContext.OnConfiguring和AspCore Startup.ConfigureServices中都定义了optionsBuilder时,预期的结果是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的ASP.NET核心具有此类,该类首先被调用
My ASP.NET core has this class which gets called first
public class Startup
{
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<IssuerContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc();
}
我的情况是这样的:
public class IssuerContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connString = "Server=(localdb)\\mssqllocaldb;Database=HavenServer;ConnectRetryCount=0;Trusted_Connection=True;MultipleActiveResultSets=true\"";
optionsBuilder
.UseLoggerFactory(MyConsoleLoggerFactory)
.EnableSensitiveDataLogging(false)
.UseSqlServer(connString, options => options.MaxBatchSize(150));
base.OnConfiguring(optionsBuilder);
}
当在两个位置中定义了看似重叠的选项时,预期的SQLServer选项配置是什么?
What is the expected SQLServer options configuration when seemingly overlapping options are defined in two locations?
推荐答案
查看全文