- [Instructor] Now that we've created…and configured our new data context class,…I'll show you how to put this new class to good use…by storing and retrieving the blog post…for our demo application.…Since we've already done all of the dirty work…of creating and configuring the data context class,…all that's left is to simply inject it into our controllers.…So, let's open up our blog controller again…and start by injecting a instance…of the blog data context class into the constructor.…Now that we have that, I can add the following lines…to the create action to save the newly…submitted post to the database.…
Notice how saving the post to the database…is a two step process.…Entity Framework works on the Unit of Work pattern,…which is really just a fancy way of saying…that first you tell the data context everything…that you want to do.…For example, adding a new post to the database.…Then, the second step is to tell the data context…to actually go ahead and execute what you've asked for,…which we do by calling the save changes method on line 76.…
Author
Updated
5/3/2019Released
12/6/2016- Building blocks of ASP.NET Core applications
- Creating a new project
- Responding to HTTP requests
- Serving static files
- Understanding the MVC pattern
- Handling requests with controllers
- Routing
- Rendering HTML with Razor
- Rendering data, view markup, and view logic
- Creating HTML forms
- Validating form data
- Reading and writing from a database with Entity Framework
- Improving the user experience
- Exposing data with a web API
- Securing your ASP.NET application
Skill Level Intermediate
Duration
Views
Related Courses
-
Introduction
-
Welcome1m 16s
-
What you should know2m 6s
-
What's new2m 33s
-
-
1. The Basics
-
Create a new project4m 44s
-
Respond to HTTP requests5m 32s
-
Serving static files2m 18s
-
Use custom configuration4m 21s
-
2. The Model-View-Controller (MVC) Pattern
-
Understand routing4m 24s
-
3. Render HTML with Views
-
Render HTML with Razor3m 51s
-
-
4. Work with Data
-
Validate form post data5m 55s
-
5. Creating Reusable Components
-
6. Secure Your Application
-
Conclusion
-
Next steps1m 42s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Write to a database using Entity Framework