Category: ASP.NET Core

0

You don’t need a IDesignTimeDbContextFactory

If you have ever gotten the error message, that tells you to add IDesignTimeDbContextFactory to your project, when doing EF Core migrations. This particular one: Unable to create an object of type ‘MyContext’. Add an implementation of ‘IDesignTimeDbContextFactory’ to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. You will probably be scratching your head, asking some questions and maybe even swear a little. Because the console will tell you to implemnt a IDesignTimeDbContextFactory so that is But don’t fret, you don’t need one. You can avoid it by having making sure of the following: The entire solution must be buildable and be able to run! If you have a project that cannot build, you can exclude it with the build configuration manager. Default constructor For the system to...

Nuget + XML docs + Swagger 8

Add NuGet package XML documentation to Swagger

Copy XML documentation from NuGet package to project build folder! At my current client, we are building an API that is put together by re-usable “API parts”, eg. ASP.NET Core Application Parts, which works wonders by the way. We can have multiple parts of the API split into small NuGet packages that can be re-used in other systems, that way we only have to implement system specific code, the rest is reused, including documentation etc. Talking about documentation, brings us directly to the issue. We use SwashBuckle to generate our Swagger definition and Swagger UI, and Swashbuckle requires XML documentation, to be able to include documentation from our Controllers and models. I thought we could probably just add a checkbox “Add XML documentation from NuGet package, on build”, but… Unfortunately...

Redis connection lost 0

Redis connection issues

At my current client, we have been dealing with an ongoing problem while scaling their cloud systems to the ever increasing customer-base. As it is with any software that needs to scale, we’ve been seeing and solving scalability problems along the way. Anyone who has ever dealt with scaling a system to accommodate a lot of concurrent users, knows that issues will be showing up places you aren’t expecting. While scaling the system, we’ve made it more resilient and fault tolerant, and also learned to mitigate many of the problems as they are arising. We’ve improved logging and metrics, so we know exactly what is happening, and can see stability problems before they affect the end-users. Redis loses connection, and will not reconnect In our system, we use StackExchange.Redis(v1.2.6) to...

1

Re-use Controllers, Views and Tag-helpers in ASP.NET Core

I recently ran into a situation, where I needed to implement the same functionality, the same views and even the same tag-helpers for different customers. Like most other developers I hate copy-pasting code that should be shared across multiple projects. I had come across a similar need a few years back, but remembered that it was cumbersome in ASP.NET 3-5, to achieve this, and the solutions back then didn’t feel right. But since my recent switch to dotnet core, I knew there was a chance that Microsoft had a prepared an early christmas present for me. So I started researching my options, searching for titles similar to this blog post, and finally found a solution on the third place on google (Yes I was that desperate). Introducing Application Parts /...