时间:2021-07-01 10:21:17 帮助过:4人阅读
在 startup.cs 中添加数据库服务
public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); // Add application services. services.AddTransient<IEmailSender, EmailSender>(); services.AddMvc(); }
启动项目进行连接测试即可。
asp.net core 中 sql server 2017 数据库连接测试
标签:figure includes cti cat des role end 数据库连接 use