When it comes to working with data, we will need to create at least two types of classes. We need to create one or more classes to map the tables in the database, where each class represents a row of data in the corresponding table. You also need at least one class that represents the database itself, which will inherit from DbContext
. To start with, let's create a class with the same structure as the Person
table from the Chapter 1, Introducing Entity Framework, with properties for id and the first and last names. Here is how the class looks in C#:
public class Person { public int PersonId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
Tip
Downloading the example code
You can download the example code fies from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and...