-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add IsRelational(), IsSqlServer(), IsInMemory(), etc. (or GetProviderName()) on DatabaseFacade #6983
Comments
Another alternative is to use As an aside, I'm not sure if I would class this as a bug or not, but it's definitely Unexpected Behaviour in my opinion. Feels a bit like a leaky abstraction, but this is mostly a consequence of my wonky architecture in my application. |
InMemory is not a relational provider, and therefore does not support migrations |
SQLite in in-memory mode is definitely the way to go if you want to do things like migrations. As @ErikEJ mentioned, InMemory is not intended to be a relational database. The Migrations feature is only contained in the relational libraries since it doesn't really make sense for all types of databases. So InMemory doesn't even depend on it. We're going to update the docs to point folks more heavily towards SQLite rather than InMemory. Leaving open so that we can discuss making migrations not-throw (and just no-op) when the provider doesn't have migrations. This should probably be a "throw but allow a flag that stops it throwing" approach because there could be relational providers that just haven't implemented migrations yet. |
Cool, good to hear. Totally understand that InMemory is not relational, but the error doesn't really convey that very well. :( |
EF Team Triage: we want to improve the exception message to explain that migrations is not supported by the provider and add sugar to ask if the database supports this functionality (e.g. |
Merge with #8566 ? |
@ErikEJ |
Already fixed by #8545? |
Ping @roji |
Checked and all are implemented except |
any plan for |
@WeihanLi This issue is in the Backlog milestone with the This issue is also marked with |
thanks for the info @ajcvickers |
Steps to reproduce
Given the following class:
When used in the following manner:
The issue
The above code will grant the following error on the line of
MigrateAsync
when executingDoWorkAsync
:This only occurs with the in memory database from my experience and works just fine with the others I've used (which is just sqlite). I would have expected this to have just "worked"; if an in memory schema cannot be created, then make the migration be a no-op.
I can resolve this by providing my own service provider but this involves having to mock not only IMigrator but any other service that the database uses, like
IServiceScopeFactory
. This is a lot of work to have an integration test in an in memory database that utilises migrations. The other option would be to leave this section of the code untested.Further technical details
EF Core version:
1.0.1
,Microsoft.EntityFrameworkCore.InMemory
is also1.0.1
.Operating system: OSX Sierra 10.12.1
Visual Studio version: using VS Code 1.5.3
The text was updated successfully, but these errors were encountered: