Chapter 6. Simplify data access with object-relational mappers
This chapter covers
- Implementing a data-access layer with an object-relational mapper (ORM)
- Comparing a micro-ORM (Dapper) with a full-featured ORM (Entity Framework Core)
- Using Microsoft.Extensions libraries to build a data-access layer
Your implementation of supply chain management software was a success, and now Widget Corporation would like to expand its capabilities. They want touchscreens for their assembly-line workers; daily, weekly, and monthly reports; and a bunch of other new features. The head of your consulting company decides that this should be a product that you can sell to other customers, so she starts hiring new team members to help you build it.
The low-level data-access layer you built worked great when there was only one client and one database. Now you’ve got to think about appealing to customers with all kinds of databases. Your team members also find that the code for interacting with the relational database is tedious and subject to human error. They suggest using an ORM, but there are so many choices, and you’re not sure which one to use.