小编A. *_*ith的帖子

EF 6启用 - 迁移无法查找上下文

我试图在EF 6.1.3 - .NET 4.5中设置EF代码首次迁移.

我的解决方案中有多个项目,启动项目正在进行中Songbirds.Web.我创建了一个名为Songbirds.Dal.EntityFramework包含我的存储库,数据库上下文和迁移的项目.

我创建了我的上下文类:

namespace Songbirds.Dal.EntityFramework
{
    public class SongbirdsDbContext : IdentityDbContext<ApplicationUser>, IUnitOfWork
    {
        public SongbirdsDbContext()
            : this("name=SongbirdsDBContext")
        {
        }
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

整个解决方案构建正确,没有错误.

我进入项目管理器控制台并将默认项目设置为Songbirds.Dal.EntityFramework并运行enable-migrations命令,我收到以下错误:

PM> enable-migrations
No context type was found in the assembly 'Songbirds.Dal.EntityFramework'.
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下结果显式指定Context Type:

PM> enable-migrations -ContextTypeName Songbirds.Dal.EntityFramework.SongbirdsDbContext
The context type 'Songbirds.Dal.EntityFramework.SongbirdsDbContext' was not found in the assembly 'Songbirds.Dal.EntityFramework'.
Run Code Online (Sandbox Code Playgroud)

SongbirdsDbContext是Songbirds.Dal.EntityFramework项目的一部分.我做错了什么想法以及为什么它没有认识到背景?

c# entity-framework ef-migrations

6
推荐指数
1
解决办法
4517
查看次数

标签 统计

c# ×1

ef-migrations ×1

entity-framework ×1