Join Jess Chadwick for an in-depth discussion in this video Solution, part of Learning ASP.NET Core MVC.
- [Instructor] In order to solve this challenge,…you needed to convert the SpecialsDataContext…into an entity framework DbContext…and then add an I.D. field to the Special class…to act as its primary key in the database.…Notice how I updated the existing…get monthly specials method to just…return the collection of Specials from the database.…Creating methods like this on your Db context classes…is not only supported, I'd encourage it.…
You also needed to configure the context…in just the way that I configured the blog data context.…First, remove the old registration…for the SpecialsDataContext…and replace it with an AddDbContext registration…and finally, you needed…to run the application at least one time,…so that entity framework would create the database for you.…
Once the database is created,…you can go in and add all…of the Specials data that you like.…With the data in place, you can go back, refresh the page,…and there you have it.…No more hard-coded Specials data.…Now that I've shown you the solution for this challenge,…
Author
Released
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
-
C#: Design Patterns
with Reynald Adolphe1h 22m Intermediate -
Tooling with NPM Scripts
with Ray Villalobos1h 21m Intermediate
-
Introduction
-
Welcome1m 16s
-
What you should know2m 6s
-
Challenges1m 11s
-
-
1. The Basics
-
Create a new project5m 14s
-
Respond to HTTP requests5m 32s
-
Serve static files3m 9s
-
Use custom configuration4m 42s
-
2. The Model-View-Controller (MVC) Pattern
-
Understand routing4m 24s
-
3. Render HTML with Views
-
Render HTML with Razor3m 51s
-
Challenge1m 29s
-
Solution1m 48s
-
-
4. Work with Data
-
Validate form post data5m 55s
-
Challenge44s
-
Solution1m 45s
-
5. Improve User Experience with Ajax and Web APIs
-
Expose web API endpoints4m 7s
-
Challenge31s
-
Solution2m 12s
-
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: Solution