EF7: The term 'add-migration' is not recognized as the name of a cmdlet

后端 未结 6 1332
傲寒
傲寒 2021-01-01 22:02

I have framework version set to: dnx46 in project.json. Also have the following packages:

  \"dependencies\": {
    \"EntityFramework.Commands\": \"7.0.0-rc1         


        
相关标签:
6条回答
  • 2021-01-01 22:23

    The only way I managed to get EntityFrameworkCore.Tools (which includes Add-Migration) working with the latest EF Core & VS 2015 was to manually call the init script from the Package Manager Console like so:

    PM> %UserProfile%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview1-final\tools\init.ps1
    
    0 讨论(0)
  • 2021-01-01 22:23

    Currently EF migrations are not supported out of the box:

    https://github.com/aspnet/EntityFramework/issues/4497

    0 讨论(0)
  • 2021-01-01 22:29

    As ErikEJ mentioned, there is no "enable-migrations". You will need to use "Add-Migrations" instead. See official docs for EF Core's Powershell commands here: http://docs.efproject.net/en/latest/cli/powershell.html

    There appears to be a bug in NuGet and Package Manager Console in some versions of Visual Studio. If cmdlets are not recognized after adding the Commands package, try restarting VS.

    Also, dnx commands will not be supported after RC1. New (forthcoming) dotnet tooling will be available for RC2. See https://github.com/aspnet/EntityFramework/issues/3925

    0 讨论(0)
  • 2021-01-01 22:43

    There is no "enable-migrations" command in EF Core (EF7).

    Just use "add-Migration"

    0 讨论(0)
  • 2021-01-01 22:44

    To add a new migration in EF7 use this command :

    dnx ef migrations add YourMigrationUniqueName
    
    0 讨论(0)
  • 2021-01-01 22:47

    This is what worked for me to solve this issue:

    Run:

    Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
    

    In project.json add this (if not there already) to the "tools" section:

    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final",
    

    Useful reference: https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html

    0 讨论(0)
提交回复
热议问题