Skip to content

Commit 5e04450

Browse files
committed
Option to try Postgres
1 parent 945e3ce commit 5e04450

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Example5.MvcWebApp.AzureAdB2C/Startup.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public Startup(IConfiguration configuration, IWebHostEnvironment env)
3131
// This method gets called by the runtime. Use this method to add services to the container.
3232
public void ConfigureServices(IServiceCollection services)
3333
{
34-
var connectionString = _configuration.GetConnectionString("DefaultConnection");
3534
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
3635
.AddMicrosoftIdentityWebApp(identityOptions =>
3736
{
@@ -55,8 +54,15 @@ public void ConfigureServices(IServiceCollection services)
5554
{
5655
options.PathToFolderToLock = _env.WebRootPath;
5756
})
57+
//************************************************
58+
//To try using Postgres then:
59+
//1. Edit the PostgreSqlConnection string in the appsettings file to your Postgres server
60+
//2. Comment out the UsingEfCoreSqlServer method
61+
//3. Uncomment the UsingEfCorePostgres
62+
.UsingEfCoreSqlServer(_configuration.GetConnectionString("DefaultConnection"))
63+
//.UsingEfCorePostgres(_configuration.GetConnectionString("PostgreSqlConnection"))
64+
//************************************************
5865
.AzureAdAuthentication(AzureAdSettings.AzureAdDefaultSettings(false))
59-
.UsingEfCoreSqlServer(connectionString)
6066
.RegisterAddClaimToUser<AddRefreshEveryMinuteClaim>()
6167
.AddRolesPermissionsIfEmpty(Example5AppAuthSetupData.RolesDefinition)
6268
.AddAuthUsersIfEmpty(Example5AppAuthSetupData.UsersRolesDefinition)

Example5.MvcWebApp.AzureAdB2C/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"ConnectionStrings": {
3-
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Example5.MvcWebApp.AzureAdB2C;Trusted_Connection=True;MultipleActiveResultSets=true"
3+
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Example5.MvcWebApp.AzureAdB2C;Trusted_Connection=True;MultipleActiveResultSets=true",
4+
"PostgreSqlConnection": "host=127.0.0.1;Database=AuthP-Example5;Username=postgres;Password=LetMeIn"
45
},
56
"AzureAd": {
67
"Instance": "https://login.microsoftonline.com/",

0 commit comments

Comments
 (0)