Simple EF Core Example with Migrations
- SQL Server Installed
- EF Core Tools installed: `dotnet tool install --global dotnet-ef`` -- NB! This updates to latest EF Core, you may need to specify version depending on version of EF Core you are using.
- Clone the repo
- Update `appsettings.json``, specifying connection string to an empty database you have created in SQL Server e.g.
{ ... "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\ProjectModels;Database=MyDatabaseName;Trusted_Connection=True;MultipleActiveResultSets=true" }, ... }
dotnet ef database update
to apply the migration- Run the project
- Includes an example of using
Option<T>
as a model property with Configurations, seeUserConfiguration.cs
- Registers
OptionJsonConverter<T>
in Program.cs to handle serialization/deserialization ofOption<T>
in JSON - Still need to register
OptionJsonConverter<T>
inProgram.cs
for Swagger