当尝试添加迁移add-migration "Inicial" -Verbose
时,出现此错误消息:
No migrations configuration type was found in the assembly 'DevIO.UI.Site'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
我遵循了消息说明并键入了命令Enable-Migrations
,但仍然存在错误
No context type was found in the assembly 'DevIO.UI.Site'
我该怎么办?
答案 0 :(得分:0)
假设您的解决方案中已有一个DbContext
类,则需要知道它在哪个项目中。您应该在该项目中添加迁移。如果为此使用Visual Studio包管理器控制台,则需要将默认项目设置为包含DbContext
的项目(即,在包管理器控制台顶部的下拉列表中)。
答案 1 :(得分:0)
实体框架不同于实体框架核心。您正在使用Entity Framework(我们知道这是因为EF Core不包含Enable-Migrations
命令),但是您的DbContext
来自Microsoft.EntityFrameworkCore
名称空间。如果将using Microsoft.EntityFrameworkCore
替换为using System.Data.Entity
,则它应该是Entity Framework的正确DbContext
类。
答案 2 :(得分:0)
我认为,如果安装名为Microsoft.EntityFrameworkCore.Tools的NuGet软件包,它将解决此问题。