DDD Value Objects With Entity Framework Core

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 and interact with it, and often times, entities are the only objects developers create when modeling the system. Value objects provide a wealth of benefits though when applied appropriately.

Continue reading “DDD Value Objects With Entity Framework Core”

Why You Should Read the .NET Core Source Code

In the first five years that I was working as a developer I didn’t once bother to read the .NET framework source code. I’m going to go out on a limb and say that this is probably the case for most software developers. We work with the .NET framework and associated tools and libraries every day, but we seldom care about how they really work or what’s contained within. Now, don’t get me wrong, the whole point of a framework is to shield you from having to know the underlying implementation details and knowing the entire framework is not necessary. I would argue though that knowing parts of the framework and how they work opens up opportunities and affords certain benefits.
Continue reading “Why You Should Read the .NET Core Source Code”

Paging in Entity Framework Core

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 need to choose the correct approach for what you want to accomplish. Continue reading “Paging in Entity Framework Core”

Query Filters and Automated Audit Columns

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 found almost universally in every system are audit columns like “DateCreated” and “DateUpdated”. This is actually very simple to implement, so this is going to be a fairly short post.
Continue reading “Query Filters and Automated Audit Columns”

Maximizing Entity Framework Core Query Performance

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 write queries in a performant manner and developers that are more comfortable with SQL want to develop everything in their technology of choice. Entity Framework is not a silver bullet for everything. There are times when it simply can’t deliver the performance needed or when it is simply functionally incapable of doing what is necessary due to limitations of the framework. That being said, there is no reason you can’t write the vast majority of your application with it and reap all the benefits it provides.
Continue reading “Maximizing Entity Framework Core Query Performance”

IdentityServer4 in ASP.NET Core Part 1

If you’ve worked with APIs at all in .NET Core then you have probably had the need to work with tokens for security. You could roll your own set up just using the underlying functionality in ASP.NET Identity, or you could enable easy mode and use something like IdentityServer4. There are other options out there for you to choose from, but this post will focus on IdentityServer4. Our application is going to consist of an API, a web application for IdentityServer4 and a Javascript based client. The source code for this post can be found here.
Continue reading “IdentityServer4 in ASP.NET Core Part 1”