1

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.

4
  • I'd refer you to Jon Skeet's helpful hints on how to write a good question. Say at least, what "identity" are you talking about? What have you tried (not "any possible changes")? Commented Nov 16, 2022 at 18:46
  • Could you please share your dataAccessLayer details? You have to register your repository in your program.cs while building the app which is missing here. Commented Nov 17, 2022 at 3:29
  • For instance, you should do like this builder.Services.AddScoped<IUnitOfWork, UnitOfWork>(); Commented Nov 17, 2022 at 3:31
  • i already add scoped which you mentioned above for unitofwork Commented Nov 17, 2022 at 10:53

1 Answer 1

1

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()

Sign up to request clarification or add additional context in comments.

3 Comments

actually if i deleted the scaffolding identity,it works properly,but after adding identity than error will apears,so scoped works properly before adding identity
Yes, I got your point, as the error tell us may be there are dependency you keep on DataAccessLayer with your Identity. By the way, could you please share your identity details and DataAccessLayer so that it would be more easier to assist you.
@hassanghori hi how did you resolve this error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.