Building an EF Core model

In both Visual Studio 2017 and Visual Studio Code, add three class files to the project named Northwind.cs, Category.cs, and Product.cs.

Your DbContext-derived class should have an overridden method named OnConfiguring. This will set the database connection string. If you want to use SQL Server, then you must uncomment the UseSqlServer method call. If you want to use SQLite, then you must uncomment the UseSqlite method call.

Modify the class file named Northwind.cs, as shown in the following code:

using Microsoft.EntityFrameworkCore; namespace Packt.CS7 { // this manages the connection to the database public class Northwind : DbContext { // these properties map to tables in the database public DbSet<Category> Categories ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.