In this write-up, I will explain how to easily and quickly set up your database using Entity Framework Core in a .NETCore project using the factory pattern to connect your entities to your database.
Steps to reproduce:
Add a new folder for models (Where you would put your entities).
Add a new class inside this folder and include some properties. This class will be our unique model used for this example. This class must have one property with the Key attribute. (One entity as an example with two properties).
Add a new class in the root of this project, named SampleContext. This class will be our context class that will be used to connect with the database. This class will inherit from DbContext.
Declare the sample model created as a dbset and set up the constructor.
At this point, you have to open the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and set the default project to "EntityFrameworkFactory".