在Apple M1 电脑上使用.net 5测试一个开源项目,使用dotnet cli命令执行数据库迁移时出错
huangxing@huangxingdeMacBook-Air Fanxing.Database.Migrations % dotnet ef migrations add DefaultDbInfo -c DefaultDbContext --framework net5.0
Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
- The following frameworks were found:
5.0.12 at [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
6.0.0 at [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=osx.11.1-x64
huangxing@huangxingdeMacBook-Air Fanxing.Database.Migrations % dotnet ef migrations add DefaultDbInfo
Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
- The following frameworks were found:
5.0.12 at [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
6.0.0 at [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=osx.11.1-x64
解决方案:
dotnet ef migrations add DefaultDbInit -c defaultdbcontext --project Fanxing.Database.Migrations/Fanxing.Database.Migrations.csproj --startup-project Fanxing.Web/Fanxing.Web.Entry.csproj
重点:添加--project指定默认项目,添加--startup-project指定启动项目