Skip to content

Commit

Permalink
Removed <PackageReference Include="Microsoft.AspNetCore.Http.Abstract…
Browse files Browse the repository at this point in the history
…ions" Version="2.2.0" /> and therefor also applicationBuilder.UseOrganizationContext().
  • Loading branch information
HansKindberg committed Nov 29, 2024
1 parent a1d7bcb commit f535ee2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 145 deletions.
8 changes: 6 additions & 2 deletions .samples/.NET 6.0/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using RegionOrebroLan.Organization.Data.Builder.Extensions;
using RegionOrebroLan.Organization.Data;
using RegionOrebroLan.Organization.Data.DependencyInjection.Extensions;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -9,7 +9,11 @@

var app = builder.Build();

app.UseOrganizationContext();
using(var scope = app.Services.CreateScope())
{
scope.ServiceProvider.GetRequiredService<OrganizationContext>().Database.Migrate();
}

app.UseRouting();
app.MapRazorPages();

Expand Down
8 changes: 6 additions & 2 deletions .samples/.NET 8.0/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using RegionOrebroLan.Organization.Data.Builder.Extensions;
using RegionOrebroLan.Organization.Data;
using RegionOrebroLan.Organization.Data.DependencyInjection.Extensions;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -9,7 +9,11 @@

var app = builder.Build();

app.UseOrganizationContext();
using(var scope = app.Services.CreateScope())
{
scope.ServiceProvider.GetRequiredService<OrganizationContext>().Database.Migrate();
}

app.UseRouting();
app.MapRazorPages();

Expand Down
9 changes: 7 additions & 2 deletions .samples/.NET Core 3.1/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RegionOrebroLan.Organization.Data.Builder.Extensions;
using RegionOrebroLan.Organization.Data;
using RegionOrebroLan.Organization.Data.DependencyInjection.Extensions;

namespace Application
Expand All @@ -24,7 +24,12 @@ public virtual void Configure(IApplicationBuilder app)
throw new ArgumentNullException(nameof(app));

app.UseDeveloperExceptionPage();
app.UseOrganizationContext();

using(var scope = app.ApplicationServices.CreateScope())
{
scope.ServiceProvider.GetRequiredService<OrganizationContext>().Database.Migrate();
}

app.UseRouting();
app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); });
}
Expand Down
27 changes: 0 additions & 27 deletions Source/Project/Builder/Extensions/ApplicationBuilderExtension.cs

This file was deleted.

1 change: 0 additions & 1 deletion Source/Project/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<VersionSuffix></VersionSuffix>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(PackageReferenceVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(PackageReferenceVersion)" />
Expand Down

This file was deleted.

7 changes: 5 additions & 2 deletions Tests/Integration-tests/OrganizationContextFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RegionOrebroLan.Organization.Data;
using RegionOrebroLan.Organization.Data.Builder.Extensions;
using RegionOrebroLan.Organization.Data.DependencyInjection.Extensions;

namespace IntegrationTests
Expand Down Expand Up @@ -78,7 +77,11 @@ protected internal virtual async Task Create_Test(bool createTwice, IServiceColl
using(var serviceProvider = services.BuildServiceProvider())
{
var applicationBuilder = new ApplicationBuilder(serviceProvider);
applicationBuilder.UseOrganizationContext();

using(var scope = applicationBuilder.ApplicationServices.CreateScope())
{
await scope.ServiceProvider.GetRequiredService<OrganizationContext>().Database.MigrateAsync();
}

try
{
Expand Down

0 comments on commit f535ee2

Please sign in to comment.