Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 58 additions & 150 deletions AStar.Dev.Web.slnx

Large diffs are not rendered by default.

Binary file added src/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 AStar Development, Jason Barden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions src/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update
2 changes: 1 addition & 1 deletion src/aspire/AStar.Dev.Web.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
.WithReference(apiService)
.WaitFor(apiService);

builder.Build().Run();
await builder.Build().RunAsync();
Binary file added src/astar.ico
Binary file not shown.
10 changes: 5 additions & 5 deletions src/modules/apis/AStar.Dev.Admin.Api/AStar.Dev.Admin.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.1" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Aspire.RabbitMQ.Client.v7" Version="9.5.2" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified src/modules/apis/AStar.Dev.Admin.Api/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions src/modules/apis/AStar.Dev.Files.Api/AStar.Dev.Files.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="9.5.2" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.1" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="13.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Aspire.RabbitMQ.Client.v7" Version="9.5.2" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions" Version="22.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.0" />
<PackageReference Include="Z.Linq.Async" Version="1.0.3" />
<PackageReference Include="ZLinq" Version="1.5.3" />
<PackageReference Include="ZLinq" Version="1.5.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified src/modules/apis/AStar.Dev.Files.Api/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.6" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="SkiaSharp" Version="3.119.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions" Version="22.1.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.1.0" />
</ItemGroup>
Expand Down
Binary file modified src/modules/apis/AStar.Dev.Images.Api/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.10.0" />
<PackageReference Include="Microsoft.Identity.Web.TokenAcquisition" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
<PackageReference Include="Microsoft.Identity.Web.TokenAcquisition" Version="4.2.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.Admin.Api.Client.Sdk/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.10.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.Api.Client.Sdk.Shared/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Api.HealthChecks/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/nuget-packages/AStar.Dev.Api.Usage.Sdk/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 AStar Development, Jason Barden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions src/nuget-packages/AStar.Dev.Api.Usage.Sdk/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.1" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.0" />
</ItemGroup>

<PropertyGroup>
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.AspNet.Extensions/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.Files.Api.Client.SDK/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Fluent.Assignments/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Guard.Clauses/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.Images.Api.Client.SDK/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Infrastructure.AdminDb/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Infrastructure.FilesDb/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Infrastructure.UsageDb/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ApiUsageContext(ConnectionString connectionString)

/// <summary>
/// </summary>
public DbSet<ApiUsageEvent> ApiUsage { get; set; }
public DbSet<ApiUsageEvent> ApiUsage { get; set; } = null!;

/// <summary>
/// The overridden OnModelCreating method.
Expand Down
Binary file modified src/nuget-packages/AStar.Dev.Infrastructure/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Logging.Extensions/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Technical.Debt.Reporting/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Test.Helpers.EndToEnd/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Test.Helpers.Integration/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Test.Helpers.Unit/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Test.Helpers/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/nuget-packages/AStar.Dev.Usage.Api.Client.SDK/AStar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-AStar.Dev.FilesDb.MigrationService-52142518-78e8-4b1f-8a08-363d619e2970</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="13.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\aspire\AStar.Dev.Web.Aspire.Common\AStar.Dev.Web.Aspire.Common.csproj" />
<ProjectReference Include="..\..\aspire\AStar.Dev.Web.ServiceDefaults\AStar.Dev.Web.ServiceDefaults.csproj" />
<ProjectReference Include="..\..\nuget-packages\AStar.Dev.Infrastructure.FilesDb\AStar.Dev.Infrastructure.FilesDb.csproj" />
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions src/services/AStar.Dev.FilesDb.MigrationService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AStar.Dev.FilesDb.MigrationService;
using AStar.Dev.Infrastructure.FilesDb.Data;
using AStar.Dev.Web.Aspire.Common;
using AStar.Dev.Web.ServiceDefaults;

HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.AddServiceDefaults();
builder.AddSqlServerDbContext<FilesContext>(AspireConstants.Sql.FilesDb);
builder.Services.AddHostedService<Worker>();

builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing.AddSource(Worker.ActivitySourceName));

IHost host = builder.Build();
await host.RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"AStar.Dev.FilesDb.MigrationService": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}
85 changes: 85 additions & 0 deletions src/services/AStar.Dev.FilesDb.MigrationService/Worker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Diagnostics;
using AStar.Dev.Infrastructure.FilesDb.Data;
using AStar.Dev.Infrastructure.FilesDb.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;

namespace AStar.Dev.FilesDb.MigrationService;

public class Worker(IServiceProvider serviceProvider, IHostApplicationLifetime hostApplicationLifetime) : BackgroundService
{
public const string ActivitySourceName = "Migrations";
private static readonly ActivitySource ActivitySource = new(ActivitySourceName);

protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
using Activity? activity = ActivitySource.StartActivity("Migrating database", ActivityKind.Client);

try
{
using IServiceScope scope = serviceProvider.CreateScope();
FilesContext dbContext = scope.ServiceProvider.GetRequiredService<FilesContext>();

await EnsureDatabaseAsync(dbContext, cancellationToken);
await RunMigrationAsync(dbContext, cancellationToken);
await SeedDataAsync(dbContext, cancellationToken);
}
catch(Exception ex)
{
_ = (activity?.AddException(ex));
}

hostApplicationLifetime.StopApplication();
}

private static async Task EnsureDatabaseAsync(FilesContext dbContext, CancellationToken cancellationToken)
{
IRelationalDatabaseCreator dbCreator = dbContext.GetService<IRelationalDatabaseCreator>();

IExecutionStrategy strategy = dbContext.Database.CreateExecutionStrategy();

await strategy.ExecuteAsync(async () =>
{
if(!await dbCreator.ExistsAsync(cancellationToken)) await dbCreator.CreateAsync(cancellationToken);
});
}

private static async Task RunMigrationAsync(FilesContext dbContext, CancellationToken cancellationToken)
{
IExecutionStrategy strategy = dbContext.Database.CreateExecutionStrategy();

await strategy.ExecuteAsync(async () =>
{
await dbContext.Database.MigrateAsync(cancellationToken);
});
}

private static async Task SeedDataAsync(FilesContext dbContext, CancellationToken cancellationToken)
{
var exists = dbContext.Files.Any(detail => detail.DirectoryName.Value == "mock" && detail.FileName.Value == "Fake");

if(exists) return;

FileDetail firstTicket = new()
{
DirectoryName = new DirectoryName("mock"),
FileName = new FileName("Fake"),
ImageDetail = new ImageDetail(),
FileHandle = new FileHandle("Mock Handle"),
FileSize = 123,
IsImage = true,
FileAccessDetail = new FileAccessDetail { DetailsLastUpdated = DateTime.UtcNow, },
};

IExecutionStrategy strategy = dbContext.Database.CreateExecutionStrategy();

await strategy.ExecuteAsync(async () =>
{
await using IDbContextTransaction transaction = await dbContext.Database.BeginTransactionAsync(cancellationToken);
_ = await dbContext.Files.AddAsync(firstTicket, cancellationToken);
_ = await dbContext.SaveChangesAsync(cancellationToken);
await transaction.CommitAsync(cancellationToken);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Loading
Loading