-
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
Throw a better exception when using EF Core tooling with MAUI #25938
Comments
Hi @AWildTeddyBear , thank you for the detailed bug report. Does this same issue happen with a regular .NET MAUI project (without Blazor)? |
I am currently working on trying to reproduce this in MAUI preview 7, taking a bit of setting up at the moment and running into issues described here: dotnet/maui#2235 |
yep, just tried this for the first time and I am getting the same error; including with the WinUI project. |
I can reproduce this in the latest dev bits of .NET MAUI. Apparently this is a long-known EF Core issue, but I'm not sure what the solution is. I'm digging deeper to see what the root issue is and how we can fix. |
Lots of matches on the EF repo, all duped around the issue I previously mentioned: https://github.com/dotnet/efcore/issues?q=is%3Aissue+The+specified+deps.json+ |
And even an issue logged on the AspNetCore repo: dotnet/aspnetcore#17751 So either way I feel like this likely isn't a .NET MAUI root cause, but something more general with VS or EF. Also, I reproed this in a regular .NET MAUI project (no Blazor), so this isn't Blazor-specific. |
It appears that this is currently not supported because EF needs to be able to run part of your app's code, but because your app's code targets an environment that can be run locally (Android, in this case), it isn't supposed to work. But, the error you're getting is of course not ideal. Fortunately, there are workarounds to this. In general, you need to move your DbContext and related types to a separate class library project that targets You can learn more in these docs:
I'm also transferring this issue to the EF Core repo so that the experience can be improved, at least in terms of detecting unsupported scenarios and offering better error messages and guidance. |
Notes from triage:
|
Description
Upon trying to create migrations in a MAUI + Blazor project, you are met with an error message "The specified deps.json does not exist"
MAUI seems to not generate this file unlike a normal .NET 6 project, and EntityFramworkCore depends on this file for creating or applying migrations.
This only happens when targeting mobile only on MAUI (including mac), UWP is likely unaffected.
Steps to Reproduce
Open Visual Studio 2022 Enterprise with MAUI installed (as instructed here)
Create a new .NET MAUI Blazor App project
Unload/Delete the WinUI project (not necessary, but UWP is not needed for this project)
Right click your MAUI project to Properties and change Target frameworks from
net6.0-ios;net6.0-android;net6.0-maccatalyst
tonet6.0-android
-- Target OS and Target OS version should automatically change (sometimes it's not immediate after you save, you might have to close the properties window and re-open before you see it change)Add the following packages to your project via your .csproj file (you can alternatively download the respective current preview versions of these packages manually via the package manager):
Test.cs
It will look like the following:
Open the Package Manager Console in your project (View -> Other Windows -> Package Manager Console)
Type "Add-Migration Initial" and press Enter
Both Add-Migration and Update-Database both pass the build, but immediately fail afterwards with "The specified deps.json [project path\bin\debug\net6.0-android\project name.deps.json] does not exist" and no migration is created.
Expected Behavior
Add-Migration should create a migration based on the project that the EntityFrameworkCore database is setup on (in this case, MAUI)
Update-Database should apply an existing migration built by Add-Migration and build a SQLite database.
Actual Behavior
Both Add-Migration and Update-Database both pass the build, but immediately fail afterwards with "The specified deps.json [project path\bin\debug\net6.0-android\project name.deps.json] does not exist" and no migration is created or applied.
Basic Information
Screenshots
Workaround
No current workaround known -- possible you can create the migrations in a different project in .NET 5, or .NET 6 and port them over to your MAUI project, including the SQLite database created.
The text was updated successfully, but these errors were encountered: