可以设置本地调试环境配置

This commit is contained in:
falcon 2020-06-28 13:42:05 +08:00
parent 335b335f7b
commit 91b37a6dbf
3 changed files with 16 additions and 6 deletions

View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.5",
"commands": [
"dotnet-ef"
]
}
}
}

View File

@ -8,9 +8,10 @@
}
},
"profiles": {
"IIS Express": {
"FalconIIS": {
"commandName": "IISExpress",
"environmentVariables": {
"DbConnStr": "Server=.\\SQLSERVER2008R2;Database=ReportService;User ID=sa;Password=111",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -24,8 +20,9 @@ namespace ReportService
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
var connStr = Environment.GetEnvironmentVariable("DbConnStr")
??this.Configuration.GetValue<string>("Database:ReportService");
services.AddDbContext<RSDbContext>(b => {
var connStr = this.Configuration.GetValue<string>("Database:ReportService");
b.UseSqlServer(connStr);
});