I have created an Entity Framework Core project and it is working fine and I am able to generate migrations through Visual Studio.
But I want to generate SQL scripts through Azure Devops CI and deployment through CD. I am unable to do it.
By adding this command
dotnet ef migrations script --project $(Build.SourcesDirectory)\SampleEFCoreApplication\SampleEFCoreApplication.csproj -o $(build.artifactstagingdirectory)\migrations\scripts.sql
This generates the entire SQL script. But next time, if I have to make any changes in my model, it again regenerates the entire SQL script. But I only want the changes to appear if I make any model changes. How can I do that ?
This is how my CI looks in Azure DevOps
You can use the --idempotent option which will add code to the script so that only the appropriate migrations are applied to the database. This effectively makes the sql script the equivalent of running
update-database in the package manager console.