O'Reilly logo

Code-First Development with Entity Framework by Sergey Barskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving a new record to the database

It is time to add some data to our table in the created database. We will insert a row, which is sometimes called a record. A record in the People table consists of values in three columns: PersonId, FirstName, and LastName. These values are going to be based on property values of an instance of the Person class, which is mapped to the People table. This is an important concept to remember. When we create entity classes, their purpose is to map to tables. There are some exceptions to this rule, which we will see in later chapters. This table is represented by a collection-based property in our Context class.

This property's type is DbSet of Person and its name is People. Conceptually, you can think of adding ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required