这就是.NET 5 我在 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) 中使用了IDbInitializer dbInitializer,但在.NET 6中我无法执行这项工作。
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
dbInitializer.Initialize();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
这就是.NET 6.0
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
我之前在 .NET 5.0 中使用 dbInitializer.Initialize(),但是在 .NET 6.0 中无法使用了。请问该怎么办?请帮忙解决。