We started this chapter by enumerating a number of things we couldn’t implement due to our Dummy Data Provider limitations; in order to overcome these, we chose to replace it with a real Data Provider built upon a persistent Database.
Entity Framework Core seemed an obvious choice to get what we want, so we added its relevant packages to our project; we briefly enumerated the available Data Modeling approaches and resorted to using Code-First due to its flexibility.
Right after that, we proceeded to create our entity classes--ApplicationUser
, Quiz
, Question
, Answer
and Result
--along with a set of relationships taking advantage of the renowned Entity Framework Core’s Convention over Configuration approach. Then, we built our ApplicationDbContext
class accordingly.
After completing our Data Model, we chose the Database Engine, quickly resorting to the Visual Studio's default MSSQL LocalDb
instance; we added the connection string to the appsettings.json
file and passed it to ApplicationDbContext...