You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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':
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
The text was updated successfully, but these errors were encountered:
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'
: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
The text was updated successfully, but these errors were encountered: