diff options
author | Javier Calvarro Nelson <jacalvar@microsoft.com> | 2021-10-11 17:17:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 17:17:35 +0300 |
commit | 64a6ddc5019ead9f5140c92c46ec4d8f6303b9fb (patch) | |
tree | 92bc6f2647fb9b5b7a6497c02bd040359dc0ddd1 | |
parent | b861c47fa9f3856acdc3a462ee7b6307960121ed (diff) |
Apply nullabiity fixes (#24)
Throws if the connection string is not present
-rw-r--r-- | src/content/Angular-CSharp/Program.cs | 2 | ||||
-rw-r--r-- | src/content/React-CSharp/Program.cs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/content/Angular-CSharp/Program.cs b/src/content/Angular-CSharp/Program.cs index f215704..696eb55 100644 --- a/src/content/Angular-CSharp/Program.cs +++ b/src/content/Angular-CSharp/Program.cs @@ -11,7 +11,7 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. #if (IndividualLocalAuth) -var connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); +var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); builder.Services.AddDbContext<ApplicationDbContext>(options => #if (UseLocalDB) options.UseSqlServer(connectionString)); diff --git a/src/content/React-CSharp/Program.cs b/src/content/React-CSharp/Program.cs index f215704..696eb55 100644 --- a/src/content/React-CSharp/Program.cs +++ b/src/content/React-CSharp/Program.cs @@ -11,7 +11,7 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. #if (IndividualLocalAuth) -var connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); +var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); builder.Services.AddDbContext<ApplicationDbContext>(options => #if (UseLocalDB) options.UseSqlServer(connectionString)); |