Sharing my best software development tips and tricks. From quick tips to actual guides and solutions.
This article explains how to fix an annoying issue with Microsoft’s SDK for CosmosDb v3 – it comes with a Newtonsoft.Json dependency, that most of Microsoft’s recent packages have let go of. With .NET Core 3.1 having shipped with System.Text.Json included, and (mostly) replacing Newtonsoft.Json, it’s kind of the preferred option. However, CosmosDb v3 SDK doesn’t support it and by default requires you to use Newtonsoft.Json to override the property names, if you want to – for example – map entities with PascalCase naming with…Continue reading System.Text.Json.JsonPropertyName not working for CosmosDb in .NET Core/5?
Man, do I run into all kinds of issues with the smallest Azure Functions that I develop. And it’s mostly my fault. The silver lining is that you’re here to read this article, so you probably ran into this same stuff. Well – you should be happy to hear this article describes fixes to a couple of issues – let’s see if they help you out as well! The article probably largely applies to any situation where you have a project referencing another project and…Continue reading Errors loading an assembly that’s using Microsoft Graph API
Another day, another issue. This time, I was absent-mindedly following the guidance for a project on how to generate .sql files for .NET EF Core code-first migrations. Don’t ask why that was required, but it was. My migration was simple. Adding an entity with just a few properties. And Entity Framework created my programmatic migration just fine. But when generating the SQL file, I got nothing but an empty file. No matter what was my startup project, working directory, context, target folder, or other variables…Continue reading “dotnet ef script” or “Script-Migration” producing empty .sql files?
So one day, I needed to quickly check if an identity field in a view in a Microsoft SQL Server was actually unique or not. I was running into weird issues with Entity Framework throwing an error somewhat like this: Store update, insert, or delete statement affected an unexpected number of rows (2) Or somewhat like this: Type: DbUpdateConcurrencyExceptionStore update, insert, or delete statement affected an unexpected number of rows ([row count]). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540…Continue reading How to form a parameterized SQL query to find duplicates in a table.
This article describes how to configure your .NET Core application to serialize objects in camelCase instead of PascalCase. I guess this is another quick note – something that should be simple, but I couldn’t remember how to do it from the top of my head, and the solution turned out to be a bit unintuitive. I guess that makes it worth documenting because I’ll run into this again for sure. Anyway – let’s take a closer look at the actual issue at hand, shall we?…Continue reading How to serialize to JSON in camelCase using .NET Core?
This article explains another simple fix to an annoying issue. I guess that’s how I start like every other one of my little tutorials, but hey, it’s true! I suppose I just have a knack for running into issues that come with poorly documented fixes or workarounds that are obvious but only in hindsight… Right? Anyway, this time my WebSocket requests were not being handled as such by my ASP.NET Controllers. “IsWebSocketRequest” was suggested by IntelliSense, but it would always be null in the code.…Continue reading HttpContext.WebSockets.IsWebSocketRequest always null in .NET Core?
So, you’re running a PowerShell command that requires a connection to PowerShell gallery, but you run into an error message, somewhat like this: “Unable to find repository ‘https://www.powershellgallery.com/api/v2’. This can happen when you’re running something like Install-Module or Update-Module. This pretty much blocks you from doing anything that would require the use of new modules – so, quite a lot. Worth fixing, then. 😁 Problem The whole error message might be somewhat like this: What gives? Posts Related to “Solving “Unable to find repository ‘https://www.powershellgallery.com/api/v2’.””:How…Continue reading Solving “Unable to find repository ‘https://www.powershellgallery.com/api/v2’.”
This article explains a kind of weird fix to a pretty annoying issue with a legacy service. And I’m not just calling it legacy because it’s WCF – I’m calling it legacy because it’s old. The particular piece of software was developed about 7 years ago (2014-ish)! It had worked for quite a while – but now it was down. I know, I know – 2014 is not THAT old. There’s surely COBOL that’s been running since the 70s, if not before. But in the…Continue reading How to force an outdated .NET project to use TLS 1.2?
Okay. So I needed to figure out what locales certain machines support, and what kind of DateTime formats those would produce. Being the crafty coder I am, I set out to copy-paste some readymade code from docs.microsoft.com. As a side note, after Microsoft opened the docs out to community contributions, I have had far less need to browse StackOverflow for my carefully curated code snippets of questionable quality. I’m going to regard that as a minor victory on the path to friendlier developer communities. Preface…Continue reading Experiment: DateTime formats
This article describes how to fix and tweak your pre-build directives in Visual Studio – just in case they refuse to work properly. Because yeah, apparently that sometimes just randomly happens. But fear not – there’s a stupid and ugly, but definitely thoughtful workaround available! Also, sorry for the confusing title. I’m taking suggestions for a more descriptive one – but this one was kind of difficult to word clearly. Anyway – on to the topic of the day! Problem So you’re either trying to…Continue reading How to fix a build configuration that’s not available as a build directive in Visual Studio?
I’m using Entity Framework in most of the projects that I’m working on – and for the most part, it’s a pleasure to work with. But as always, there are plenty of chances to run into issues – so obviously, I stumble into all of the rare stuff that IS broken! This one I hadn’t really seen before – “No database provider has been configured for this DbContext”. This time I encountered the issue while setting up a new project and getting started working on…Continue reading Fixing “No database provider has been configured for this DbContext” in Entity Framework Core
Another day, another issue with Azure Functions! For such a simple and powerful tool, it sure does produce a lot of topics for blog articles! 😁 So let’s get down to fixing another Azure Functions configuration issue. But wait – what WAS the problem again? Problem When firing up your Azure Functions project locally, this error is what you’re confronted with: “Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger, kafkatrigger. You can run ‘func azure functionapp fetch-app-settings ‘…Continue reading How to fix “Missing value for AzureWebJobsStorage in local.settings.json” when you’re debugging Azure Functions locally?
Azure DevOps pipelines have a pretty handy feature called Pipeline Caching. It’ll help you avoid annoyingly long NuGet package restores in your builds. And that makes sense – why would you restore packages again and again and again, if you’re not updating your dependencies meanwhile? And especially in the case of CI or CD pipeline, you’ll end up having a pipeline running constantly without packages actually getting bumped up – so your NuGet task is downloading the same packages over and over again. That’s where…Continue reading Azure DevOps Pipelines Caching
Well, that title is a mouthful. But it’s the topic for today, so what can you do? That said, this article should be pretty topical, as the issue started popping up only a few days ago. Chances are it’ll be patched soon enough, but in the meantime, it’s always useful to document the fix! Problem When running or debugging Azure Functions locally, your runtime just blurts our this error and fails to compile your functions: [2021-01-11T10:28:11.495Z] A host error has occurred during startup operation ‘0d00defa-b8bd-4fb8-9794-b0e5950a4c38’.…Continue reading How to fix “System.IO.FileSystem: Could not find a part of the path \AppData\Local\AzureFunctionsTools\Releases\3.17.0\workers. Value cannot be null. (Parameter ‘provider’)” when running Azure Functions locally?
This article explains one easy workaround to a lot of Visual Studio authentication issues. Personally, it’s helped me multiple times when Cloud Explorer has gotten into a weird authentication loop or Visual Studio stops seeing my MSDN subscription. And it also helps you clean up any old and unused credentials – such as the ones you only used once in 2018 to log into a customer’s Azure environment to debug an issue they had with their AppInsights extension on an app service (and that ended…Continue reading How to nuke the Identity Cache in Visual Studio?
This was a fun one! Suddenly, while running or debugging my ASP.NET Core 3.1 application, I started getting errors about missing assemblies, along the lines of “FileNotFoundException: Could not load file or assembly Microsoft.AspNetCore.Components.Forms”. These DLL files were not required a minute earlier – nor did requiring them really make much sense in my mind – but there was a nonsensical, easy fix, so in the end, it was all good! But let’s go through this thing in order. What was the problem? Problem So,…Continue reading Fixing unexpected Microsoft.AspNetCore package errors after a dependency update
Hey, another funny case. “Funny” as in “the error message is misleading and googling didn’t really help”, but also as in “a colleague knew the answer right off the bat because he already fixed it in another project”. This time the documentation was in fact there, it just wasn’t there to be found. Anyway – what have I broken this time? Problem When you’re calling Graph API with both $filter and $count, for example: Instead of the expected number of found items, you get results…Continue reading Graph API throws “$count is not currently supported.” when you KNOW it’s supported?
Another quick one – I’m sure this doesn’t apply to all cases, but I’m still logging it in case someone (like myself) stumbles upon the issue and finds help here. I was building a solution with some Azure Functions fetching and populating data in a database, and was planning on building a UI for browsing the data at some point later on – but I actually got stuck on the second step already :) While adding the database to my project, and running Add-Migration in…Continue reading “An assembly specified in the application dependencies manifest was not found” when running Add-Migration in Entity Framework Core?