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

Startup projecft targets platform 'Android'. Entity Framework Core Package Manager Console Tools don't support this platform #9940

Closed
MessiasRu opened this issue Sep 6, 2022 · 1 comment
Labels
platform/android 🤖 t/bug Something isn't working

Comments

@MessiasRu
Copy link

MessiasRu commented Sep 6, 2022

Description

Can't make migrations in a new MAUI Blazor project.
This issue happends with CLI and PM
I followed guides but they do not have this problem.

Steps to Reproduce

  • Create a new MAUI Blazor project
  • Install EfCore
  • Install EFCore.Sqlite
  • Install EfCore.Tools -> error
  • Edit csproj and change PackageReference of EfCore.Tools to:
  • PM> Add-Migration init

Startup project 'MauiApp1' targets platform 'Android'. The Entity Framework Core Package Manager Console Tools don't support this platform. See https://aka.ms/efcore-docs-pmc-tfms for more information.

Link to public reproduction project repository

https://github.com/MessiasRu/MauiBlazorEfIssue

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

10.0.19041.0

Did you find any workaround?

No response

Relevant log output

PM> add-migration init
Build started...
Build succeeded.
Startup project 'MauiApp1' targets platform 'Android'. The Entity Framework Core Package Manager Console Tools don't support this platform. See https://aka.ms/efcore-docs-pmc-tfms for more information.
@MessiasRu MessiasRu added the t/bug Something isn't working label Sep 6, 2022
@jfversluis
Copy link
Member

If you follow the link from the error message you will get to a page that explains the situation pretty well. This is not supported. The official guidance here is to create a separate library/project that you can use to get around this. I will paste the text that is currently in that link here for reference.

When that still causes issues, please open an issue with the Entity Framework project. Thanks!

The Package Manager Console tools work with .NET Core or .NET Framework projects. Apps that have the EF Core model in a .NET Standard class library might not have a .NET Core or .NET Framework project. For example, this is true of Xamarin and Universal Windows Platform apps. In such cases, you can create a .NET Core or .NET Framework console app project whose only purpose is to act as startup project for the tools. The project can be a dummy project with no real code — it is only needed to provide a target for the tooling.

Why is a dummy project required? As mentioned earlier, the tools have to execute application code at design time. To do that, they need to use the .NET Core or .NET Framework runtime. When the EF Core model is in a project that targets .NET Core or .NET Framework, the EF Core tools borrow the runtime from the project. They can't do that if the EF Core model is in a .NET Standard class library. The .NET Standard is not an actual .NET implementation; it's a specification of a set of APIs that .NET implementations must support. Therefore .NET Standard is not sufficient for the EF Core tools to execute application code. The dummy project you create to use as startup project provides a concrete target platform into which the tools can load the .NET Standard class library.

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants