dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.76k stars 3.18k forks source link

efcore not support Maui 'Add-Migration' ? #30268

Closed yangbocheng closed 1 year ago

yangbocheng commented 1 year ago

Ask a question

in a maui program, couldn't use 'Add-Migration' to generate migration,

if i counldn't use 'Add-Migration' and then do migrating, is there any way to generate a sqlite db file and table structure in phone app?

here is error:

PM> Add-Migration v1
Build started...
Build succeeded.
Startup project 'todomaui' 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.

Include your code

    <ItemGroup>
        <PackageReference Include="CommunityToolkit.Maui" Version="4.0.0" />
        <PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
        <PackageReference Include="sqlite-net-pcl" Version="1.9.141-beta" />
    </ItemGroup>

Include stack traces

Include verbose output

Include provider and version information

EF Core version: 7.0.2 Database provider: Microsoft.EntityFrameworkCore.Sqlite.Core sqlite-net-pcl Target framework: net7.0-android;net7.0-ios;net7.0-maccatalyst Operating system: IDE: (Visual Studio 2022 17.5)

ajcvickers commented 1 year ago

@yangbocheng You will need to use a dummy startup project, as described in the link.

ajcvickers commented 1 year ago

Duplicate of #26798