From the course: Learning ASP.NET Core MVC
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Represent the database using Entity Framework
From the course: Learning ASP.NET Core MVC
Represent the database using Entity Framework
- [Narrator] Now that we've got an HTML form that's posting validated data back to the server, let's use the Entity Framework library to save that data to a database. Entity Framework is an object relational mapper or ORM, which is really just a fancy way of saying that it's a tool that allows you to save and retrieve data to and from a relational database using objects rather than hand coded sequel queries. To start, I'll add a new class called blog data context to our project. Note that the name of this class is not important at all, you can name it any name that you like. Then, I'll have this new class inherit the Entity Framework base class, Db Context. In order to tell Entity Framework that we'll be using this class to represent our database. Notice how Visual Studio is highlighting the Db Context base class to indicate that it doesn't know what it is. So, go ahead and add a reference to the entity framework package to make that error go away. In order for the data context to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Create strongly typed HTML forms4m 5s
-
(Locked)
Post form data to controller actions4m 9s
-
(Locked)
Validate form post data5m 55s
-
(Locked)
Use tag helpers to simplify forms5m 7s
-
(Locked)
Represent the database using Entity Framework6m 9s
-
(Locked)
Write to a database using Entity Framework1m 35s
-
(Locked)
Read from a database using Entity Framework2m 26s
-
-
-
-