Bulky icon indicating copy to clipboard operation
Bulky copied to clipboard

Section 8 - lecture 1/2

Open bertoldimatteo opened this issue 2 years ago • 3 comments

Hi, I can adding identity scaffold but when I try to start IIS express I have this error in program.cs on var app = builder.Build();

"System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BookWebsite.DataAccess.Repository.IRepository.IUnitOfWork Lifetime: Scoped ImplementationType: BookWebsite.DataAccess.Repository.UnitOfWork': Unable to resolve service for type 'BookWebsite.DataAccess.ApplicationDbContext' while attempting to activate 'BookWebsite.DataAccess.Repository.UnitOfWork'.)'"

I searched online but I can't find solution....it's weird because I follow all step on the video.

bertoldimatteo avatar Feb 05 '23 18:02 bertoldimatteo

The error message informs us that there is a failure in ApplicationDbContext.

Please check if the ApplicationDbContext class is correctly implemented and it's in the correct namespace.

leo-tavares avatar Feb 05 '23 18:02 leo-tavares

I checked and ApplicationDbContext is the same as teacher and I checked namespace. The fun fuct is that previously that i change in ApplicationDbContext : DbContext all works fine, when I change in IdentityDbContext the nightmare become :(

bertoldimatteo avatar Feb 06 '23 09:02 bertoldimatteo

You can upload your code in a github, i can check the files?

Once accidentally when generating the "Identity scaffold" I realized that it was creating a second DbContext inside Areas/Identity. See the print below.

image

leo-tavares avatar Feb 06 '23 12:02 leo-tavares