- Runtime:
.NET 6
- Database:
PostgreSQL
docker push huhubun/bunblog.api
Add-Migration Init -StartupProject "BunBlog.API" -Project "BunBlog.Data"
Update-Database -StartupProject "BunBlog.API" -Project "BunBlog.Data"
If it is the first time to run, you need to install dotnet-ef
first
dotnet tool install --global dotnet-ef
If you have installed dotnet-ef
before version 6, you need to upgrade dotnet-ef
dotnet tool update --global dotnet-ef
Then you can use the dotnet-ef
command
# Add migration
dotnet-ef migrations add Init --startup-project "./src/BunBlog.API/BunBlog.API.csproj" --project "./src/BunBlog.Data/BunBlog.Data.csproj"
# Update database
dotnet-ef database update --startup-project "./src/BunBlog.API/BunBlog.API.csproj" --project "./src/BunBlog.Data/BunBlog.Data.csproj"
# Generate db script
dotnet-ef migrations script --startup-project "./src/BunBlog.API/BunBlog.API.csproj" --project "./src/BunBlog.Data/BunBlog.Data.csproj" --idempotent --output ./scripts/script.sql