Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistence/added use migration creator #146

Merged
merged 3 commits into from
Jan 24, 2024
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
14 changes: 14 additions & 0 deletions NArchitecture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Persistence.DependencyInjection", "src\corePackages\Core.Persistence.DependencyInjection\Core.Persistence.DependencyInjection.csproj", "{E1F0BD02-5781-4309-B469-DFDA36C2462E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Persistence.WebApi", "src\corePackages\Core.Persistence.WebApi\Core.Persistence.WebApi.csproj", "{93910DFF-42FA-4A27-9076-45F276E99143}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -157,6 +161,14 @@ Global
{A06975C0-631D-4E8B-8106-D1C8E3A05D19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A06975C0-631D-4E8B-8106-D1C8E3A05D19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A06975C0-631D-4E8B-8106-D1C8E3A05D19}.Release|Any CPU.Build.0 = Release|Any CPU
{E1F0BD02-5781-4309-B469-DFDA36C2462E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1F0BD02-5781-4309-B469-DFDA36C2462E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1F0BD02-5781-4309-B469-DFDA36C2462E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1F0BD02-5781-4309-B469-DFDA36C2462E}.Release|Any CPU.Build.0 = Release|Any CPU
{93910DFF-42FA-4A27-9076-45F276E99143}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93910DFF-42FA-4A27-9076-45F276E99143}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93910DFF-42FA-4A27-9076-45F276E99143}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93910DFF-42FA-4A27-9076-45F276E99143}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -186,6 +198,8 @@ Global
{82A827A4-0FAB-4A81-8BC9-444571117AA7} = {403A7B6A-EDB3-4B56-8DF2-A92A3247C721}
{061DAFB0-CD87-48E9-9ADA-B3C9C85E7306} = {403A7B6A-EDB3-4B56-8DF2-A92A3247C721}
{A06975C0-631D-4E8B-8106-D1C8E3A05D19} = {07E15C51-014F-4C05-B709-C273D2D4E78C}
{E1F0BD02-5781-4309-B469-DFDA36C2462E} = {403A7B6A-EDB3-4B56-8DF2-A92A3247C721}
{93910DFF-42FA-4A27-9076-45F276E99143} = {403A7B6A-EDB3-4B56-8DF2-A92A3247C721}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9208CFCE-156A-49CD-9E43-32CE67AAB957}
Expand Down
1 change: 0 additions & 1 deletion src/starterProject/Persistence/Contexts/BaseDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public BaseDbContext(DbContextOptions dbContextOptions, IConfiguration configura
: base(dbContextOptions)
{
Configuration = configuration;
Database.EnsureCreated();
}

protected override void OnModelCreating(ModelBuilder modelBuilder) =>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions src/starterProject/Persistence/Persistence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\corePackages\Core.Persistence.DependencyInjection\Core.Persistence.DependencyInjection.csproj" />
<ProjectReference Include="..\..\corePackages\Core.Persistence\Core.Persistence.csproj" />
<ProjectReference Include="..\Application\Application.csproj" />
</ItemGroup>

Expand Down
19 changes: 10 additions & 9 deletions src/starterProject/Persistence/PersistenceServiceRegistration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Application.Services.Repositories;
using Core.Persistence.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Persistence.Contexts;
using Persistence.MigrationConfigurations.Services;
using Persistence.Repositories;

namespace Persistence;
Expand All @@ -12,14 +12,15 @@ public static class PersistenceServiceRegistration
{
public static IServiceCollection AddPersistenceServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<BaseDbContext>(options => options.UseInMemoryDatabase("nArchitecture"));
services.AddScoped<IEmailAuthenticatorRepository, EmailAuthenticatorRepository>();
services.AddScoped<IOperationClaimRepository, OperationClaimRepository>();
services.AddScoped<IOtpAuthenticatorRepository, OtpAuthenticatorRepository>();
services.AddScoped<IRefreshTokenRepository, RefreshTokenRepository>();
services.AddScoped<IUserRepository, UserRepository>();
services.AddScoped<IUserOperationClaimRepository, UserOperationClaimRepository>();
services.AddScoped<IMigrationCreatorService, MigrationCreatorService>();
_ = services.AddDbContext<BaseDbContext>(options => options.UseInMemoryDatabase("BaseDb"));
_ = services.AddDbMigrationApplier(buildServices => buildServices.GetRequiredService<BaseDbContext>());

_ = services.AddScoped<IEmailAuthenticatorRepository, EmailAuthenticatorRepository>();
_ = services.AddScoped<IOperationClaimRepository, OperationClaimRepository>();
_ = services.AddScoped<IOtpAuthenticatorRepository, OtpAuthenticatorRepository>();
_ = services.AddScoped<IRefreshTokenRepository, RefreshTokenRepository>();
_ = services.AddScoped<IUserRepository, UserRepository>();
_ = services.AddScoped<IUserOperationClaimRepository, UserOperationClaimRepository>();

return services;
}
Expand Down
10 changes: 5 additions & 5 deletions src/starterProject/WebAPI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Application;
using Core.CrossCuttingConcerns.Exceptions.Extensions;
using Core.Persistence.WebApi;
using Core.Localization.WebApi;
using Core.Security;
using Core.Security.Encryption;
Expand All @@ -10,7 +11,6 @@
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Persistence;
using Persistence.MigrationConfigurations.Extensions;
using Swashbuckle.AspNetCore.SwaggerUI;
using WebAPI;

Expand Down Expand Up @@ -55,7 +55,7 @@
opt =>
opt.AddDefaultPolicy(p =>
{
p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
_ = p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
})
);
builder.Services.AddSwaggerGen(opt =>
Expand All @@ -82,8 +82,8 @@
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(opt =>
_ = app.UseSwagger();
_ = app.UseSwaggerUI(opt =>
{
opt.DocExpansion(DocExpansion.None);
});
Expand All @@ -92,7 +92,7 @@
if (app.Environment.IsProduction())
app.ConfigureCustomExceptionMiddleware();

_ = app.UseMigrationCreator();
_ = app.UseDbMigrationApplier();

app.UseAuthentication();
app.UseAuthorization();
Expand Down
1 change: 1 addition & 0 deletions src/starterProject/WebAPI/WebAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\corePackages\Core.Localization.WebApi\Core.Localization.WebApi.csproj" />
<ProjectReference Include="..\..\corePackages\Core.Mailing\Core.Mailing.csproj" />
<ProjectReference Include="..\..\corePackages\Core.Persistence.WebApi\Core.Persistence.WebApi.csproj" />
<ProjectReference Include="..\..\corePackages\Core.WebAPI\Core.WebAPI.csproj" />
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
Expand Down
Loading