- Microsoft.EntityFrameworkCore.SqlServer (for SQL Server usage)
First you’ll want to create your data context, you’ll see that mine resides in the data access layer project for my Contact Manager application; which follows best practices and patterns, but makes EF complain (video has a work-around). My context uses POCO objects from my Model project which has no references to Entity Framework or any other external libraries.
Next create the database tables by launching the NuGet Package Manager console and typing in:
- add-Migration <YourContext>
Your done! The following video demonstrates how I had a failing unit test because three were no tables in my database. With the above two steps the tables were generated.
In figure 1 we show the POCO class that generated the tables, and relationships, shown in figure 2.
Video 1 fixing failing unit test because there are tables in the database
Figure 1 Contact Class
Figure 2 Schema generated from Contact Class
Figure 3 Context code – referencing only POCO objects