Skip to content

Commit

Permalink
Configure DB & Redis & add migration bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
reidst authored Dec 8, 2023
1 parent 0a525fb commit 148501a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main_iseegreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Install .NET EF Core
run: dotnet tool install -g dotnet-ef --version 7.0.14

- name: Generate database migration bundle
run: dotnet ef migrations bundle --runtime linux-x64 -p DotNetCoreSqlDb/DotNetCoreSqlDb.csproj -o ${{env.DOTNET_ROOT}}/myapp/migrate

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
Expand Down
8 changes: 7 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext<ISeeGreenContext>(options =>
options.UseSqlite(builder.Configuration.GetConnectionString("ISeeGreenContextSQLite") ?? throw new InvalidOperationException("Connection string 'ISeeGreenContext' not found.")));
options.UseSqlServer(builder.Configuration.GetConnectionString("AZURE_SQL_CONNECTIONSTRING") ?? throw new InvalidOperationException("Connection string 'AZURE_SQL_CONNECTIONSTRING' not found.")));

builder.Services.AddStackExchangeRedisCache(options =>

Check failure on line 12 in Program.cs

View workflow job for this annotation

GitHub Actions / build

'IServiceCollection' does not contain a definition for 'AddStackExchangeRedisCache' and no accessible extension method 'AddStackExchangeRedisCache' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in Program.cs

View workflow job for this annotation

GitHub Actions / build

'IServiceCollection' does not contain a definition for 'AddStackExchangeRedisCache' and no accessible extension method 'AddStackExchangeRedisCache' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
{
options.Configuration = builder.Configuration["AZURE_REDIS_CONNECTIONSTRING"];
options.InstanceName = "SampleInstance";
});

builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<ISeeGreenContext>();
Expand Down
2 changes: 1 addition & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"ISeeGreenContextSQLite": "Data Source=ISG.db"
"AZURE_SQL_CONNECTIONSTRING": "Data Source=iseegreen-server.database.windows.net,1433;Initial Catalog=iseegreen-database;User ID=iseegreen-server-admin;Password=877GX404CJ8S7MS8$"
}
}

0 comments on commit 148501a

Please sign in to comment.