Skip to content

Commit

Permalink
remove in memory database
Browse files Browse the repository at this point in the history
  • Loading branch information
a.civier committed May 17, 2024
1 parent 3147b8e commit c2814e2
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 65 deletions.
2 changes: 0 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Don't Nod</Company>
<!-- Uncomment the following line to use InMemoryDatabase -->
<DefineConstants>$(DefineConstants);USE_SQL_LITE</DefineConstants>
<Product />
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ https://devblogs.microsoft.com/nuget/introducing-central-package-management/ -->
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5" />
Expand Down
10 changes: 0 additions & 10 deletions src/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Identity.Web" />
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="DotSwashbuckle.AspNetCore" />
<PackageReference Include="DotSwashbuckle.AspNetCore.Annotations" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/Data/ApplicationDbContextInitialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

public class ApplicationDbContextInitialiser(ILogger<ApplicationDbContextInitialiser> logger, ApplicationDbContext context)
{
#if USE_SQL_LITE
public async Task InitialiseAsync()
{
try
Expand All @@ -19,7 +18,6 @@ public async Task InitialiseAsync()
throw;
}
}
#endif

public async Task SeedAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public static async Task InitialiseDatabaseAsync(this WebApplication app)
using var scope = app.Services.CreateScope();

var initialiser = scope.ServiceProvider.GetRequiredService<ApplicationDbContextInitialiser>();
#if USE_SQL_LITE

await initialiser.InitialiseAsync();
#endif

await initialiser.SeedAsync();
}
Expand Down
4 changes: 0 additions & 4 deletions src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti
{
options.AddInterceptors(sp.GetServices<ISaveChangesInterceptor>());

#if USE_SQL_LITE
options.UseSqlite(connectionString);
#else
options.UseInMemoryDatabase("AppDatabase");
#endif
});

services.AddScoped<IApplicationDbContext>(provider => provider.GetRequiredService<ApplicationDbContext>());
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
.AddDbContext<ApplicationDbContext>((sp, options) =>
{
options.AddInterceptors(sp.GetServices<ISaveChangesInterceptor>());
#if USE_SQL_LITE
options.UseSqlite(connection);
#else
options.UseInMemoryDatabase("AppDatabase");
#endif
});
});
}
Expand Down
34 changes: 0 additions & 34 deletions tests/Application.FunctionalTests/InMemoryTestDatabase.cs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Application.FunctionalTests/TestDatabaseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ public static class TestDatabaseFactory
{
public static async Task<ITestDatabase> CreateAsync()
{
#if USE_SQL_LITE
var database = new SqliteTestDatabase();
#else

var database = new InMemoryTestDatabase();
#endif

await database.InitialiseAsync();

Expand Down

0 comments on commit c2814e2

Please sign in to comment.