Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neater error message when context type is not explicitly specified. #33680

Open
voroninp opened this issue May 6, 2024 · 0 comments
Open

Neater error message when context type is not explicitly specified. #33680

voroninp opened this issue May 6, 2024 · 0 comments

Comments

@voroninp
Copy link

voroninp commented May 6, 2024

I am experimenting (as usual) with Ef Core.

First, I attempted to add migrations to assembly which does not contain DbContext, and I got a pretty explanationry message:

No DbContext was found in assembly 'EfMigrationsBundle'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

Then I added a context without a factory, so operation executor is not able to instantiate it. And I got this error:

Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[AppDbContext]' while attempting to activate 'AppDbContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Sorry, but this of type '' is not the best way to tell me that I have not specified context type explicitly.

Btw, I agree, naming it as contextTypeName would be better =P
image

P.S. Relevant story

A man comes to the doctor.
He greets the doctor and starts to undress. He takes off his shirt, folds it along the seams, fastens the buttons and puts it on the chair. He takes off his T-shirt, folds it neatly and puts it next to his shirt. He took off his shoes and put them under the chair. He took off his socks, smoothed them out and put them next to him. He smoothed out his pants by the arrows and hung them on the back of the chair, took off his underwear, smoothed out the seams too, put them next to his T-shirt and said:
-- You know, doctor, look, I have one testicle a little higher than the other.
-- What's the big deal?
-- What's the big deal?! It's a little sloppy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants