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?
Just resolved a random issue that’s difficult enough to google, that I think it’s worth documenting! These seem to be popping up whenever you work with anything that’s fairly fresh out of oven… This particular case revolves around Visual Studio being incredibly obnoxious, and starting to throw a ton of errors on code that worked five minutes prior. In my case, the error happened after updates to Visual Studio. Always fun. Symptoms The errors started popping up in Visual Studio. Basically, I just started getting…Continue reading How to fix “The type or namespace name ‘Services’ does not exist in the namespace ‘Microsoft.AspNetCore.Components’ (are you missing an assembly reference?)”
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?
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
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