The classical approach to unit testing with Entity Framework involves mocking the database context. With Entity Framework Core we no longer need to use a library like moq or even use mocking any longer. Instead, we’re going to use Entity Framework Core’s in memory database.
Over the past decade, CQRS has become more popular and implementing it with Entity Framework Core makes it easy. We’re going to start off by discussing what CQRS is, different ways to implement it, and why Entity Framework Core is ideally suited to it. We’ll finish with examples of command and query implementations.
If you’re working with SQL Server, chances are good that you have come across the need to create an index on a guid column. In some cases, although I don’t advise it, guids are used as the primary keys on every table. This typically results in a clustered index on these columns. Other times you […]
For those who aren’t familiar, there is a concept in Domain Driven Design that distinguishes between objects with identity (entities) and those without (value objects). When we model the domain we typically think in terms of entities which are then persisted and modified over time. They form the basis for which we describe the business […]
Working with a many to many relationship in Entity Framework Core has always been one of the harder things for developers new to Entity Framework. This is going to be a short post detailing how to create them and configure the relationship. We’ll also discuss common scenarios when working with them.
If you’re using Entity Framework Core and building any non-trivial enterprise application then using data tables with paging is almost a certainty. There are two ways to do this: server side and client side. Which one you choose depends on your design and your needs. There are pros and cons associated with both so you […]
I wanted to write a quick post about using query filters and automatically populating audit columns in Entity Framework Core since I see a lot of people doing this manually still. A common scenario in most applications is to do soft deletes on everything, typically with a column like “IsDeleted”. Another common scenario that is […]
Entity Framework Core query performance is something that comes up often when working on projects that rely on it heavily. I have often heard that Entity Framework is not performant enough which then leads to everything being written as a stored procedure. Usually this happens for two main reasons: developers aren’t familiar with how to […]
Let me preface this blog post by saying that there are still times when a DTO makes sense. Also, this post is written from a .NET perspective, so some things may be different on your platform. What I want to address though is the tendency of many developers to just automatically create a set of […]
That is, it’s dead if you are using Entity Framework Core. If you’re still using straight ADO.NET, or even just dapper, then the repository pattern still probably makes sense for you. If you’re using Entity Framework, then you really aren’t gaining much from doing so anymore. Five years ago, you could reasonably argue that it […]