Create EF Context and Migrations
For starters, we need to install Entity Framework and its tools to our Infrastructure project.
Follow these steps to create the EF context:
- Just right-click on dependencies and select
Manage NuGet Packages. - Afterwards write
Microsoft.EntityFramework.Core.SqlServerin the search box and install it.
Your screen should look as follows:

- Similarly, install the
Microsot.EntityFrameworkCore.Toolspackage, as follows:

So, your project folder for Infrastructure looks as follows:

- Next, we create the
EFfolder in theInfrastructureproject and implement ourDbContextwith a class calledRestBuyContext. Make sure you have a reference to theRestBuyproject fromInfrastructure.Use this code:
Note
Go to https://goo.gl/wYLwRA to access the code.
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using RestBuy.Entities; using System; using System.Collections.Generic; using System.Text; ... void ConfigureStockAmount(EntityTypeBuilder<StockAmount...