InvalidOperationException Unable resolve service Context attempt activate Controller ASP.NET Core

preview_player
Показать описание


An unhandled exception occurred while processing the request.
InvalidOperationException: Unable to resolve service for type 'Demo_Api02.Models.API_Database01Context' while attempting to activate 'Demo_Api02.Controllers.NotesController'.
Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)

Freelancer for

ASP.NET API Core .Net5 C# .Net WPF UWP WinUI SQL Server
Рекомендации по теме
Комментарии
Автор

Thank you so much.. You saved a lot of my time. cheers

BTW in VS 2022 this line will be added in Program.cs as StartUp.cs is not there anymore

AbbasHussain
Автор

Thanks my good sir ! I spent 7hrs with a similar problem. Your line services.AddDbContext fixed it. Thanks.

thej-man
Автор

Thank you much for making this I had been stuck on this error for the past 3 hours. I am really thankful that I came across your video. God bless you!

palakmishrra
Автор

Thank you so much, I really liked your attention to detail and explanation.

vidurlutchminarain
Автор

oh my god you saved me! Thank you so much for doing this video :D

eduardofeltrin
Автор

Thank you!!!! Very good! Solve my problem.

fabiomarcelosouza