Following desenvolvedor.io - Introdução ao Entity Framework Core
- Change SQL Server SA password at
./env/db.env
- Run
docker-compose up -d
at root folder - Change application ConnectionString at
./src/Curso/Util/Configuration.cs
dotnet ef migrations add InitialMigration -p Curso/CursoEFCore.csproj -c ApplicationContext
-p Curso/CursoEFCore.csproj
--> Project which it will look at-c ApplicationContext
--> DbContext which it will look at
dotnet ef database update -p Curso/CursoEFCore.csproj -v
-v
--> Verbose mode
First, you have to create a migration, so add a property to any domain class and create a migration:
obs.: Observe that I have just one DbContext, if you have more than one, specify applying
-c <ContextName>
dotnet ef migrations add AddEmailToClient -p ./Curso/CursoEFCore.csproj
Applying migration:
dotnet ef database update -p Curso/CursoEFCore.csproj
Rolling back to InitialMigration
dotnet ef database update InitialMigration -p ./Curso/CursoEFCore.csproj
Removing the lastest migration (AddEmailToClient) files:
dotnet ef migrations remove -p ./Curso/CursoEFCore.csproj
dotnet ef migrations script -p ./Curso/CursoEFCore.csproj -o ./Curso/InitialMigration.sql
-o ./Curso/InitialMigration.sql
--> File location which the script file will be created
dotnet ef migrations script -p ./Curso/CursoEFCore.csproj -o ./Curso/Idempotent.sql -i
-i
--> Idempontent option