Skip to content

Commit

Permalink
migration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Haik committed Mar 20, 2024
1 parent 9b99f46 commit c4f8af8
Show file tree
Hide file tree
Showing 7 changed files with 1,509 additions and 16 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<PackageVersion Include="Hangfire.PostgreSql" Version="1.20.8" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<PackageReference Include="FluentValidation.AspNetCore" />
<PackageReference Include="Hangfire" />
<PackageReference Include="MediatR" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions"/>
<PackageReference Include="PandaTech.BaseConverter" />
<PackageReference Include="Pandatech.CommissionCalculator"/>
<PackageReference Include="Pandatech.Communicator"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Hangfire.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Pandatech.CleanArchitecture.Core.Entities;
using PandaTech.IEnumerableFilters.PostgresContext;

namespace Pandatech.CleanArchitecture.Infrastructure.Context;

//hint for migration: dotnet ef migrations add --project src\Pandatech.CleanArchitecture.Infrastructure\Pandatech.CleanArchitecture.Infrastructure.csproj --output-dir /Migrations
//hint for migration: dotnet ef migrations add --project src\Pandatech.CleanArchitecture.Infrastructure\Pandatech.CleanArchitecture.Infrastructure.csproj --context Pandatech.CleanArchitecture.Infrastructure.Context.PostgresContext --configuration Debug --output-dir ./Migrations
public class PostgresContext(DbContextOptions<PostgresContext> options) : PostgresDbContext(options)
{
public DbSet<UserTokenEntity> UserTokens { get; set; } = null!;
Expand All @@ -20,15 +19,3 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AssemblyReference).Assembly);
}
}

public class PostgresContextFactory : IDesignTimeDbContextFactory<PostgresContext>
{
public PostgresContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<PostgresContext>();

optionsBuilder.UseNpgsql().UseSnakeCaseNamingConvention();

return new PostgresContext(optionsBuilder.Options);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Pandatech.CleanArchitecture.Infrastructure.Context;

public class PostgresContextFactory : IDesignTimeDbContextFactory<PostgresContext>
{
public PostgresContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<PostgresContext>();

optionsBuilder.UseNpgsql().UseSnakeCaseNamingConvention();

return new PostgresContext(optionsBuilder.Options);
}
}
Loading

0 comments on commit c4f8af8

Please sign in to comment.