efcore: db.Database.Migrate(); doesn't Work on EF Core 3.1.0 for UWP Project
I have been using EF Core 2.2.6 and EF Core Tool 2.2.6 in my UWP project. Now I want to use version 3.1.0. But I cannot migrate my SQLite db at app startup. I get error at db.Database.Migrate();
Can anyone help me with how to use EF Core v3.1.0 or 3.1.1 on the UWP project? I am ready to provide you more info if you need it.
My project details:
MusicPlayer10 (UWP project, version 16299) DataModel (.NET Standard v2.0, for SQLite model) MigrationStartup (.NET Core v2.2)
Further technical details
EF Core version: 3.1.0 Database provider: SQLite Target framework: UWP 16299 Operating system: Windows 10 (OS Build 18363.XX) IDE: Visual Studio 2019
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 40 (12 by maintainers)
Commits related to this issue
- App packages updated. Bug workaround added for the change to Microsoft.Data.Sqlite v3.0 and EF Core 3.x.x. See comments for more detail — committed to hjohnson12/Kanban-Tasker by hjohnson12 4 years ago
- Microsoft.Data.SQLite: Set temp and data directory on UWP Fixes #19754 — committed to dotnet/efcore by bricelam 4 years ago
Note from team meeting: move this to the docs repo.
For anyone else that keeps their DbContext in a separate .NET Standard class library within a UWP solution, you will have to use:
We discussed this again and came to the following conclusions:
We will target this for a 3.1.x patch release, although this will need approval.
@ajcvickers , Yes, I want full support for the UWP apps. And I want
db.Database.Migrate()to work properly without explicitly defining the database location just like v 2.6.x.This is not UWP problem. It’s all about the EF Core problem. I cannot use ApplicationData in .NET Standard project if I use EF core 3.1.x and EF Core cannot migrate without explicit database file location.
Seems like EF Core and UWP are fighting with each other.
@bricelam I see similar issue on my UWP application too. Until 2.2.6, it works fine, but from 3.0.0 onwards, it fails. The only difference between what is reported vs what I see on my side is, for me, it fails to open the database.
It throws an error “SQLite Error 14: Unable to open database file”. Please find below the exact error.
Not sure if its the same error that @shakir820 is seeing on his side.
Any assistance is really appreciated. And if there is any additional details, required, please let me know that too. Thanks!!