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

Improve exception messages for "no data store configured" #2227

Closed
divega opened this issue May 19, 2015 · 0 comments
Closed

Improve exception messages for "no data store configured" #2227

divega opened this issue May 19, 2015 · 0 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@divega
Copy link
Contributor

divega commented May 19, 2015

We have seen people hit this exception several times in the betas: #2191 #2156 #2094.

The current exception message (No data stores are configured. Configure a data store by overriding OnConfiguring in your DbContext class or in the AddDbContext method when setting up services.) does not account for one of the common causes: customers will often have their derived DbContext correctly setup in their service configuration but will then bypass DI in the creation of the context by creating the context with the new keyword.

I believe we should try to say something more helpful in the exception message, e.g. something like this:

No data stores are configured. You can configure a data store by calling the AddDbContext method when setting up services and then instantiating the derived DbContext class using dependency injection, or by overriding OnConfiguring in your DbContext class.

Note that the fact it is at all possible to new a DbContext without passing any parameters to the constructor is an unfortunate effect of the decision we made to enable default constructors to work with ASP.NET and to have a DbContext with only a default constructor in the default application templates. We could also revert that decision although it has some unwanted consequences.

@rowanmiller rowanmiller added this to the 7.0.0 milestone May 20, 2015
@rowanmiller rowanmiller self-assigned this May 20, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0-rc1, 7.0.0 Sep 17, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0, 7.0.0-rc1 Oct 14, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0-rc2, 7.0.0 Dec 7, 2015
@mikary mikary assigned mikary and unassigned rowanmiller Dec 18, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0, 7.0.0-rc2 Jan 25, 2016
@rowanmiller rowanmiller assigned rowanmiller and unassigned mikary Jan 25, 2016
@mikary mikary closed this as completed in 6c4d50a Jan 26, 2016
@mikary mikary modified the milestones: 7.0.0-rc2, 7.0.0 Jan 26, 2016
@ajcvickers ajcvickers removed this from the 1.0.0-rc2 milestone Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers added this to the 1.0.0 milestone Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants