In production the application makes use of environmental variables to obscure the AzureSQL connection string. In development on your local machine you will be using a disposible SQLite database so you will probably need to do a database migration before the application will run locally.
When you clone the repository, there should not be a Migrations/
folder or a database (app.db
) but you may end up with these files from previous work, or accidental addition to the repository. If you have these files locally you may not need to do a migration, but the database will probably get cluttered fast and need to be deleted.
You can pretty much just delete Migrations/
and app.db
whenever you want and it will not break anything. There are also limitations to SQLite that will force you to delete them because you can't update the database to do what you need to do. You will lose all of the data in the database so this does not work in production.
To perform a database migration go to the project folder and run the following Bash command:
dotnet ef migrations add CreateDatabase --context DogTransport.Data.ApplicationDBContext
dotnet ef database update --context DogTransport.Data.ApplicationDBContext
Build project and its dependencies:
dotnet build
Run the application:
dotnet run
Delete the last ef migration:
dotnet ef migrations remove --context DogTransport.Models.ModelsContext
Create a new ef migration:
dotnet ef migrations add MigrationName --context DogTransport.Data.ApplicationDBContext
// Be sure to change the migration name as necessary
Update the database with new migration:
dotnet ef database update --context DogTransport.Data.ApplicationDBContext
List files available to be generated:
dotnet aspnet-codegenerator identity --listFiles
Generate code:
dotnet aspnet-codegenerator identity --files "Files.To.Be.Generated"
// Be sure to change the files to be generated string as necessary