Download SQL Server Express and install it. You will need admin privlages and TLS enabled.
Update the server name for the ConnectionStrings in the appsettings.Local.json
file from the sf_stats.Api
project to your local SQL Server instance name. appsettings.Local.json
will be ignored by git in the future.
!! - Currently the Development
appsettings is being incorrectly loaded. For now, change the server name in appsettings.Development.json
, but do not commit the changes
To enable the ability to migrate db changes via the command line, EF Core Tools needs to be installed. It is recommended to install the tool set globally.
To install the tools use the following command:
dotnet tool install --global dotnet-ef
To migrate the tools to the latest version use the following command:
dotnet tool update --global dotnet-ef
You can update your database with the latest migrations using either EF Core Tools or the EF Core Design Tools nuget package. Under the hood, they are the same. EF Core Design Tools wrap EF Core Tools in powershell and at times it can be a bit more convienient to use them from within Visual Studio. Use whatever method you prefer.
EF Core Design Tools is a nuget package that includes the EF Core Tools functionality in powershell commands. This is an easy way to generate and apply migrations from within visual studio itself. This method can be more convienent when working withing visual studio itself.
You can do this from the Package Manager Console which can be opened via View > Other Windows > Package Manager Console
Make sure to set Default project
to sf_stats.DataAccess.MSSql
Update to most recent migration
update-database
Update (or Rollback) to a specific migration
update-database <migration-name>
After completing code changes:
add-migration <migration_name>
This will generate a new migration and add it to the Migrations
folder of the sf_stats.DataAccess.MSSql
project
To remove the most recently added migration, run
remove-migration
This project is using a code-first approach for migrating data changes to the database (Microsoft SQL Server).
dotnet ef database update --project csprojpath
Note: This is a relative path from the root of the repository.
dotnet ef database update <migration_name/migration_id> --project csprojpath
Note: This is a relative path from the root of the repository.
Note2: If a value of 0 is passed in as a parameter it will revert the database to an empty state.