From 91b37a6dbf335a007789426b66ae8bd2c7a25984 Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Sun, 28 Jun 2020 13:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E8=B0=83=E8=AF=95=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReportService/.config/dotnet-tools.json | 12 ++++++++++++ ReportService/Properties/launchSettings.json | 3 ++- ReportService/Startup.cs | 7 ++----- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 ReportService/.config/dotnet-tools.json diff --git a/ReportService/.config/dotnet-tools.json b/ReportService/.config/dotnet-tools.json new file mode 100644 index 0000000..98e414c --- /dev/null +++ b/ReportService/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "3.1.5", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/ReportService/Properties/launchSettings.json b/ReportService/Properties/launchSettings.json index 1cccbb7..e96524b 100644 --- a/ReportService/Properties/launchSettings.json +++ b/ReportService/Properties/launchSettings.json @@ -8,9 +8,10 @@ } }, "profiles": { - "IIS Express": { + "FalconIIS": { "commandName": "IISExpress", "environmentVariables": { + "DbConnStr": "Server=.\\SQLSERVER2008R2;Database=ReportService;User ID=sa;Password=111", "ASPNETCORE_ENVIRONMENT": "Development" } }, diff --git a/ReportService/Startup.cs b/ReportService/Startup.cs index 67782b5..fcf8c59 100644 --- a/ReportService/Startup.cs +++ b/ReportService/Startup.cs @@ -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("Database:ReportService"); services.AddDbContext(b => { - var connStr = this.Configuration.GetValue("Database:ReportService"); b.UseSqlServer(connStr); });