Persisting Data with Entity Framework

Many applications rely on databases to store and query data. Even though there are many types of databases, including graph, key-value stores, document, relational, and so on, in this book, we will use the good old relational database (also known as RDBMS). Relational databases are the oldest and most popular type of databases, and although they may not be the best solution for every type of use case, they most certainly do a very good job in most types of applications, and they have a very mature ecosystem and set of tools. Relational databases rely on the Standard Query Language (SQL) to both define the structure and query the data of the database, and for you to use it from within a C# (or any other language) application, you have to learn the language and keep the queries as strings inside your application so that you can send them to the remote database through a designated database client. Developers like to work rapidly and seamlessly with the technologies they use, and this led to the foundations of a new approach to working with databases—Object-Relational Mappers (O/RM). Simply put, O/RM is a technique where you write your code with simple objects that represent your data model and, behind the scenes, every operation you make is translated into SQL and the results are mapped back to your objects. 

EF Core is the O/RM of choice when developing an ASP.NET Core application. In this chapter, I will show how you can use it to store data in and retrieve data from your web applications. 

In this chapter, you'll learn how to store and query data in a relational database using the EF Core. The following topics will be covered in this chapter:

  • Entity framework core overview 
  • Managing the data model using migrations 
  • Querying data 
  • Saving data 
  • Transactions

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.28.70