-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor database initialization and update project references
Removed specific package references from DatabaseProject.csproj and switched the project reference to Entities.csproj. Database initialization has been refactored to a separate method in Initializer.cs and this method is now called in Program.cs. FrameworkReference to Microsoft.AspNetCore.App was added to Database.csproj. Some changes were also made to how model configuration is handled.
- Loading branch information
Gary Woodfine
committed
Jan 18, 2024
1 parent
2c334d0
commit 6981f3a
Showing
7 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1" /> | ||
<PackageReference Include="Npgsql" Version="8.0.1" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" /> | ||
<PackageReference Include="Threenine.Database.Configuration" Version="1.0.4" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../Models/Models.csproj" /> | ||
<ProjectReference Include="../Entities/Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Entities\Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
|
||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
<Project> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/> | ||
<ItemGroup> | ||
<Using Include="placeHolder.Database.Entities" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
|
||
namespace Database.ApiSolutions | ||
{ | ||
public static class Initializer | ||
{ | ||
public static void DatabaseInitialise(this WebApplication app) | ||
{ | ||
using var scope = app.Services.CreateScope(); | ||
var context = scope.ServiceProvider.GetService<ApiSolutionContext>(); | ||
context.Database.Migrate(); | ||
} | ||
} | ||
} |