services.AddDbContext<TodoContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); }); 1. 2. 3. 4. 有时候我们需要在输出EF执行的SQL语句,这便于我们调试以及优化数据库,下面的配置就把EF日志输出到控制台 /// <summary> /// 输出日志 /// </summary> pu...
builder.Services.AddDbContextFactory<BookContext>(opt =>opt.UseSqlServer(ConfigHelper.Configuration["ConnectionStrings:BookContext"])); 为了进行本地开发,我们在appsettings.json 文件中配置数据库连接字符串,数据库连接配置如下: "ConnectionStrings": {"BookContext": "Server=.;Database=LeaseBook;Trusted_Connect...
/// <summary>/// 输出日志/// </summary>publicstaticreadonlyILoggerFactoryloggerFactory=LoggerFactory.Create(builder=>{builder.AddConsole();});publicvoidConfigureServices(IServiceCollectionservices){//省略其他代码services.AddDbContext<TodoContext>(options=>{options.UseSqlServer(Configuration.GetConnectionStri...
... public void ConfigureServices(IServiceCollection services) { services.AddDbContext<DataContext>(opts => { opts.UseSqlServer(Configuration[ "ConnectionStrings:PeopleConnection"]); opts.EnableSensitiveDataLogging(true); }); services.AddControllersWithViews().AddRazorRuntimeCompilation(); services.AddRazor...
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDatabaseDeveloperPageExceptionFilter(); services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount =true) ...
新建Data/ApplicationUserClaimsPrincipalFactory.cs 文件 using BlazorOIDC.Server.Models; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using System.Security.Claims; namespace Densen.Models.ids; public class ApplicationUserClaimsPrincipalFactory : UserClaimsPrincipalFactory<ApplicationUser, ...
services.AddDbContext<TodoContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); }); 有时候我们需要在输出EF执行的SQL语句,这便于我们调试以及优化数据库,下面的配置就把EF日志输出到控制台 ///<summary> ...
进行本地开发时,配置会从应用设置文件 (appsettings.json) 中获取数据库连接字符串。 以下示例中的 {CONNECTION STRING} 占位符是连接字符串:JSON 复制 "ConnectionStrings": { "BlazorWebAppMoviesContext": "{CONNECTION STRING}" } 下面是一个连接字符串示例:Server=(localdb)\mssqllocaldb;Databas...
// Configuration.GetConnectionString("DefaultConnection"))); //services.AddDatabaseDeveloperPageExceptionFilter(); //services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true) // .AddEntityFrameworkStores<ApplicationDbContext>(); ...
("DefaultConnection"); builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString)); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount =true) .AddEntity...