Entity Framework Core logo

How to instantiate your DbContext outside your Data project?

When you’re in your .NET Core project, it’s always easy: you just register your DbContext in ConfigureServices, and then inject it into whichever Page, View or Controller you might need it in. However, when you have another project or solution you’re working on and you’d still like to use the same DbContext and your entity classes in it, you have to find another way to do it! What should we do, then? Description Let’s first take a look at the use cases and tech stack.…Continue reading How to instantiate your DbContext outside your Data project?

.NET Core fundamentals in one picture.

How to use UriHelper or NavigationManager in .NET Core 3.0 & Blazor?

Just a quick piece of documentation, as this piece of code has changed in different versions of .NET Core 3.0 so far a few times. Need to have things like this written down somewhere! UriHelper / NavigationManager with .NET Core 3.0 Both of these helper libraries do essentially the same thing: navigate/browse/redirect the user to a different address, component, page or view in or by your web app. What you normally use this library for is exactly the same in all versions I’ve worked with,…Continue reading How to use UriHelper or NavigationManager in .NET Core 3.0 & Blazor?

A simple graphical explanation of Blazor's effect on the web development landscape.

HttpClient in Blazor

Blazor is a new (ish) framework for building web UIs with C#. It either uses SignalR to manage connections between your client-side and server-side code, or even compiles directly to WebAssembly, in both cases cutting out the need to write any pesky JavaScript yourself – pretty neat, if you ask me! However, developing your web apps with Blazor is a bit different from using ASP.NET MVC, for example. Other people have written great introductions to the tech, so I’ll stick to the problem at hand:…Continue reading HttpClient in Blazor

SOLVE ALL THE ERRORS!

‘__generated__Index.OnInitAsync()’: no suitable method found to override

Welp – just ran into this one, and as I expect others to encounter the same issue, better document in right away! So in Blazor, I was crafting a simple component that’d display some data in a nice way. Being lazy and crafty, I thought I’d copy-paste some similar code from an earlier POC I had built, since I knew it worked. The component was overriding a method called “OnInitAsync”, and it just nicely fetched data after initialized. But alas, it didn’t. Not anymore. I…Continue reading ‘__generated__Index.OnInitAsync()’: no suitable method found to override

GitHub thread about the error - and long and winding discussion about the topic.

How to resolve build failing with .NET Core 3 and Microsoft.AspNetCore.Mvc.Versioning

Building a proof-of-concept on .NET Core 3.0 preview 7 I ran into issues when developing web APIs. This release is production-ready (according to Microsoft -see below), but every now and then you run into really unintuitive and sometimes surprising issues. Go LiveNET Core 3.0 Preview 7 is supported by Microsoft and can be used in production. We strongly recommend that you test your app running on Preview 7 before deploying Preview 7 into production. If you find an issue with .NET Core 3.0, please file…Continue reading How to resolve build failing with .NET Core 3 and Microsoft.AspNetCore.Mvc.Versioning