hassan ghori
hassan ghori

Reputation: 11

Found error after adding identity in my ASP.NET Core 6 MVC app

enter image description here

I tried any possible changes but could not able to solve this please if any one know about this help me out

Could not find any solution.

When I deleted identity it works properly, but when I add new scaffolded item, it shows the error mentioned.

Upvotes: 1

Views: 462

Answers (1)

Md Farid Uddin Kiron
Md Farid Uddin Kiron

Reputation: 22495

I tried any possible changes but could not able to solve this please if any one know about this help me out

Well, lets explain your error details:

enter image description here

As the error clearly describes that you have DataAccessLayer class file with your project which contains IUnitOfWork under the IRepositoty folder which you haven't register in your program.cs file as a result you have encountered that specific error.

Solution:

Resolve the current error, you have to register all the Interface and its Implementation just right before your var app = builder.Build();

So your AddScoped should be as following:

builder.Services.AddScoped<IUnitOfWork, UnitOfWork>();
builder.Services.AddScoped<IAnotherService, AnotherService>();
.... So on

Note: Point to keep in mind all the Interface and Implementation within your DataAccessLayer should be scopped before calling builder.Build()

Upvotes: 1

Related Questions