Skip to content

Commit 048dbe1

Browse files
authored
Merge pull request #205 from EduardoPires/update-net9
fix: automatic migrations
2 parents 79cf3a6 + 0a82577 commit 048dbe1

34 files changed

Lines changed: 1120 additions & 179 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>disable</Nullable>
55
</PropertyGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\Equinox.Domain\Equinox.Domain.csproj" />
88
<ProjectReference Include="..\Equinox.Infra.Data\Equinox.Infra.Data.csproj" />
99
</ItemGroup>
1010
<ItemGroup>
11-
<PackageReference Include="AutoMapper" Version="13.0.1" />
11+
<PackageReference Include="AutoMapper" Version="14.0.0" />
1212
</ItemGroup>
1313
</Project>

src/Equinox.Domain.Core/Equinox.Domain.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>disable</Nullable>
55
</PropertyGroup>
66
<ItemGroup>

src/Equinox.Domain/Equinox.Domain.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>disable</Nullable>
55
</PropertyGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\Equinox.Domain.Core\Equinox.Domain.Core.csproj" />
88
<ProjectReference Include="..\Equinox.Infra.CrossCutting.Bus\Equinox.Infra.CrossCutting.Bus.csproj" />
99
</ItemGroup>
1010
<ItemGroup>
11-
<PackageReference Include="FluentValidation" Version="11.9.2" />
11+
<PackageReference Include="FluentValidation" Version="11.11.0" />
1212
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
1313
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
1414
<PackageReference Include="System.Security.Claims" Version="4.3.0" />

src/Equinox.Infra.CrossCutting.Bus/Equinox.Infra.CrossCutting.Bus.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>disable</Nullable>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="mediatr" Version="12.4.0" />
7+
<PackageReference Include="mediatr" Version="12.5.0" />
88
</ItemGroup>
99
<ItemGroup>
1010
<ProjectReference Include="..\Equinox.Domain.Core\Equinox.Domain.Core.csproj" />

src/Equinox.Infra.CrossCutting.Identity/Configuration/AspNetIdentityConfig.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.EntityFrameworkCore;
99
using Microsoft.Extensions.Configuration;
1010
using Microsoft.Extensions.DependencyInjection;
11+
using Microsoft.Extensions.Hosting;
1112
using Microsoft.IdentityModel.Tokens;
1213
using System;
1314
using System.Text;
@@ -38,9 +39,17 @@ public static WebApplicationBuilder AddWebIdentityConfiguration(this WebApplicat
3839

3940
private static WebApplicationBuilder AddIdentityDbContext(this WebApplicationBuilder builder)
4041
{
42+
if (builder.Environment.IsDevelopment())
43+
{
44+
45+
builder.Services.AddDbContext<EquinoxIdentityContext>(options =>
46+
options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));
47+
48+
return builder;
49+
}
50+
4151
builder.Services.AddDbContext<EquinoxIdentityContext>(options =>
42-
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"),
43-
b => b.MigrationsAssembly("Equinox.Infra.CrossCutting.Identity.Data")));
52+
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
4453

4554
return builder;
4655
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
22
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Design;
4+
using Microsoft.Extensions.Configuration;
5+
using System.IO;
6+
using System;
37

48
namespace Equinox.Infra.CrossCutting.Identity.Data
59
{
610
public class EquinoxIdentityContext : IdentityDbContext
711
{
812
public EquinoxIdentityContext(DbContextOptions<EquinoxIdentityContext> options) : base(options) { }
913
}
14+
15+
public class EquinoxIdentityContextFactory : IDesignTimeDbContextFactory<EquinoxIdentityContext>
16+
{
17+
public EquinoxIdentityContext CreateDbContext(string[] args)
18+
{
19+
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
20+
21+
var configuration = new ConfigurationBuilder()
22+
.SetBasePath(Directory.GetCurrentDirectory())
23+
.AddJsonFile("appsettings.json", optional: true)
24+
.AddJsonFile($"appsettings.{environment}.json", optional: true)
25+
.Build();
26+
27+
var builder = new DbContextOptionsBuilder<EquinoxIdentityContext>();
28+
29+
var connectionString = configuration.GetConnectionString("DefaultConnection");
30+
31+
if (environment == "Development")
32+
{
33+
builder.UseSqlite(connectionString);
34+
}
35+
else
36+
{
37+
builder.UseSqlServer(connectionString);
38+
}
39+
40+
return new EquinoxIdentityContext(builder.Options);
41+
}
42+
}
1043
}

src/Equinox.Infra.CrossCutting.Identity/Equinox.Infra.CrossCutting.Identity.csproj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>disable</Nullable>
55
</PropertyGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\Equinox.Domain\Equinox.Domain.csproj" />
88
</ItemGroup>
99
<ItemGroup>
10-
<PackageReference Include="Azure.Identity" Version="1.12.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
12-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
13-
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.7" />
14-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.7" />
15-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.7" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
17-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
10+
<PackageReference Include="Azure.Identity" Version="1.13.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.3" />
12+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.3" />
13+
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="9.0.3" />
14+
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="9.0.3" />
15+
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="9.0.3" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.3" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
1819
<PrivateAssets>all</PrivateAssets>
1920
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2021
</PackageReference>

0 commit comments

Comments
 (0)