With the release of ASP.NET Core, configuration was given a major upgrade. The new options API provides the ability to add configuration sections to the service provider and then inject them using the options interfaces. Unfortunately, I still see people injecting IConfiguration and then manually grabbing values with strings.Continue reading “Configuration in ASP.NET Core”
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.Continue reading “Testing with Entity Framework Core”
If you’ve been working in ASP.NET Core then you’ve probably been faced with the dilemma of choosing between using middleware or filters. Both middleware and filters can serve similar purposes. Choosing between them comes down to whether you need access to the MVC context.Continue reading “Middleware vs Filters ASP. NET Core”
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.Continue reading “CQRS with Entity Framework Core”
With all the security breaches in the news these days it’s important to run a vulnerability assessment on your SQL Server database. SQL Server Management Studio makes doing so simple and straight forward. Starting with SSMS 17.4 you can run an automated scan directly from the database menu.Continue reading “SQL Server Database Vulnerability Assessment”
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 may need to use a unique identifier as a secondary Id on an entity for business reasons, such as an employee id. Regardless of which type of index you use or your reasons for doing so, index fragmentation becomes a bigger issue with guids.Continue reading “Index on SQL Server Guid Column”
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.
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.
Continue reading “Many to Many Relationship Entity Framework Core”
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”
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”