One does not simply use just one DbContext with multiple ConnectionStrings in Entity Framework Core.

How to implement multiple Connection Strings for one DbContext in EF Core?

Recently, while building an app service to host a .NET Core API, I had to implement the logic for using both Read-Only and Read-Write Database Contexts for Entity Framework Core. In this particular case, it was the same database – just different contexts, because depending on the location of the app service the app was deployed in, read and write operations might actually go to different database instances, That’s really easy, right? Well… Yes and no. Essentially, it’s easy to spin up, but comes with…Continue reading How to implement multiple Connection Strings for one DbContext in EF Core?

C# & .NET

How to get the EF Core Connection String?

A while ago, I had a situation where a DbContext was misbehaving after deployed to an Azure App Service, and I needed to check the connection string it’s using directly in the code. I had reason to think my code was grabbing an outdated connection string and using a wrong database – and as you can probably imagine, that could cause some issues! However, finding the right method actually took me googling, as there were plenty of examples for Entity Framework for .NET Framework, but…Continue reading How to get the EF Core Connection String?

Miina (@minepupper) is fixing them bugs

EF Core returns null for a Navigation property

This article describes how to fix a situation, where you can’t use any of the navigation properties of your Entity Framework Core entities, since they are all null, despite data being in the database for sure. So, another day, another error. This time I can’t blame SharePoint, since I just messed up with ASP.NET Core and Entity Framework Core. :) Symptoms No matter what I’d do, I was getting null values for my navigation properties on my entities. They’d would always be null during runtime…Continue reading EF Core returns null for a Navigation property