4 Working with data
This chapter covers
- Understanding the core concepts of a Database Management System (DBMS)
- Introducing Entity Framework Core
- Building a Data Model and binding it to Entity classes
- Deploying a SQL Server Database using on-premise and cloud hosting models
- Setting up the Database context and structure using Entity Framework Core
Up to this point we have been working on our Web API using sample data created on-demand by a static procedure. Such an approach was certainly useful, as it allowed us to focus on the fundamental concepts of a REST architecture while keeping our source code as simple as possible. In this chapter we're going to get rid of that "fake" data set and replace it with a proper data source managed by means of a database.
In the first section we'll briefly review the key elements and distinctive properties of a Database Management System (DBMS), as well as the benefits of storing our data there. Right after that we'll see how we can interact with that system using Entity Framework Core (EF Core), a lightweight and extensible data access technology that allows us to work with most database services using .NET objects. More precisely, we'll learn how to use the two main development approaches provided by EF Core to either generate a Data Model from an existing DB Schema (Database-First), or manually create a Data Model and generate the DB Schema from that (Code-First), providing a concrete scenario for both.