我在project.json
文件中有一个ASP.NET Core项目:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"NLog.Extensions.Logging": "1.0.0-rtm-alpha5",
"Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview2-final"
},
将此项添加到项目文件并且Visual Studio已恢复该程序包后,我可以使用程序包管理器控制台中的add-migration
。
但每次重新打开Visual Studio时,add-migration
命令都会消失。然后我必须从依赖项中删除Microsoft.EntityFrameworkCore.Tools
并再次添加它以使命令起作用。
如何解决这个问题,以便命令始终可用?
修改
我现在使用nuget更新了依赖关系:
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"NLog.Extensions.Logging": "1.0.0-rtm-alpha5",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Design": {
"type": "build",
"version": "1.1.0-preview4-final"
},
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.NETCore.App": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.1.0"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
},
仍然是同样的问题。
编辑2:
此方法现在仅在我"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview2-final"
中添加project.json
时才有效。如果我使用"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
,则add-migration
命令根本不可用。
但是使用preview2,我仍然可以将它重新添加到project.json并重新启动VS以使其正常工作。