10 Useful software patterns for EF Core applications
This chapter covers
- Applying the separation-of-concerns principle
- Using a LINQ mapper to speed up development
- Using a domain-driven-design approach to EF Core
- Splitting your database across multiple DbContexts
- Building error-handling for database errors
This chapter introduces techniques, patterns, and packages to help you become a more productive developer. I find that I become a better developer by taking a pattern or design principle that looks promising, using it in a project, reviewing how that went, and improving the pattern in the next project. This chapter shares techniques I’ve used and perfected over many years as well as some that I’ve only just starting looking at now that EF Core has been released.
The techniques in this chapter aren’t the only ones you could use, and not all the approaches I describe will be applicable to your needs, but they’re a good mix of techniques to consider. Like me, you won’t know if an approach is useful until you’ve used it in a real-world project, but you have to start somewhere. I hope this chapter gets you thinking, so enjoy the journey.
10.1 Another look at the separation-of-concerns principle
Section 5.5.2 covered the software design principle called separation of concerns (SoC). This design principle states that a software system should be decomposed into parts that overlap in functionality as little as possible. SoC is linked to two other principles: