Join Jess Chadwick for an in-depth discussion in this video Expose data through a web API, part of Learning ASP.NET Core MVC.
- [Instructor] Now that I've added…a Web API controller to my application,…let's use that controller to save…and retrieve data in a database.…I name this controller CommentsController…because I intended to use it to add and retrieve comments.…And as I showed in the Entity Framework videos,…you need to have a class defined…in order to use Entity Framework…to interact with a database.…So, I'll start by creating the Comment Class…in the Models folder,…and populate it with a few properties.…
Notice the PostId and Post properties.…It's no coincidence that these two properties…are named similarly.…Creating the Post property of type Post…and the corresponding long property named PostId…tells Entity Framework that…this Comment entity is related to the post entity,…which will allow you to reference the Post object…as if it were part of the Comment object itself.…Then, just like with the Post entity,…I have to add this entity to a data context…in order to interact with it as a database table.…
To do this, I'll open up the BlogDataContext class…
- 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
- 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
1. The Basics
2. The Model-View-Controller (MVC) Pattern
Understand routing4m 24s
3. Render HTML with Views
4. Work with Data
5. Improve User Experience with Ajax and Web APIs
6. Secure Your Application
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.Cancel
Take 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.