In the preceding section, we added the EF Core package for SQL Server support; now we need to create a context so our models could interact with our product database. We have the Product and Category models. To do so, refer to this list:
- Add a new folder and name it Contexts--it is not compulsory to add a new folder
- In the context folder, add a new C# class and name it ProductContext--we are creating DbContext for ProductDatabase, so to make the similarity here, we are creating ProductContext
- Make sure the ProductContext class inherits the DbContext class
- Make the changes and our ProductContext class will look like this:
using FlixOne.BookStore.ProductService.Models; using Microsoft.EntityFrameworkCore; namespace FlixOne.BookStore.ProductService.Contexts ...