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 Error Message For Migrations w/InMemoryProvider #12288

Closed
ardalis opened this issue Jun 7, 2018 · 2 comments
Closed

Improve Error Message For Migrations w/InMemoryProvider #12288

ardalis opened this issue Jun 7, 2018 · 2 comments

Comments

@ardalis
Copy link

ardalis commented Jun 7, 2018

Running migrations when the project is configured to use an InMemory provider fails (as it should) but could do a much better job of informing the developer of the problem.

Suggestion: When migrations fail because the InMemory provider is configured, put information in the exception message saying something like "Migrations are not supported for the InMemory provider - did you mean to configure a database provider?"

Here is the current exception that is created when you run dotnet ef migrations add 'name':
image 1

If you read the RED exception message, it says nothing about the particular provider that is being used (well, OK, it says this might happen if you have no database provider, but that's not enough to call out that YOU CAN'T DO THIS WITH THE InMemory PROVIDER - people don't necessarily get the distinction that the InMemory provider isn't a 'database' provider). In this case the (relatively new to EF and .NET Core) developer had originally been using .UseSqlServer but switched over to .UseInMemory while making a bunch of design changes. When they were done, they forgot to switch back, and they got this error. They had no idea what had caused it and were blocked until I was able to help.

If you read the message very carfully, you'll see at the top it says "EF Core initialized AppDbContext with provider InMemory" but it doesn't do anything to call this out as particularly important. If you don't already know that this is the culprit you're unlikely to figure it out on your own.

Steps to reproduce

Create an ASP.NET Core default web application.
Choose Individual User Accounts so it creates a DbContext.
Change the DbContext to use an InMemory provider.
Run dotnet ef migrations add "name"

Further technical details

EF Core version: 2.1
Database Provider: InMemory; SqlServer
Operating system: windows 10
IDE: n/a

@ajcvickers
Copy link
Member

Duplicate of #6983

@ajcvickers ajcvickers marked this as a duplicate of #6983 Jun 8, 2018
@ardalis
Copy link
Author

ardalis commented Jun 8, 2018

Ah, so it is. Thanks. Sorry for the duplicate and hope it gets fixed soon. Cheers!

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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