在程序包管理器控制台中运行enable-migrations时出现错误 [英] I get Error when i run enable-migrations in package manager console

查看:282
本文介绍了在程序包管理器控制台中运行enable-migrations时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个ASP.NET MVC项目...当我键入enable-migrations时,我会遇到以下问题:

I am making a ASP.NET MVC project ...when i type enable-migrations i get the following eroors:

More than one context type was found in the assembly 'eManager.Web'.
To enable migrations for eManager.Web.Infrastructure.DepartmentDb, use Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb.
To enable migrations for eManager.Web.Models.UsersContext, use Enable-Migrations -ContextTypeName eManager.Web.Models.UsersContext.

推荐答案

错误消息准确地指出了问题所在以及需要执行的操作-包括需要发出的命令.显然,您的项目中有多个上下文(Web.Infrastructure.DepartmentDb和Web.Models.UsersContext),并且迁移不知道应为哪些迁移启用.您需要指向上下文类型.根据错误消息使用:

The error message exactly states what the problem is and what needs to be done - including the command that needs to be issued. Apparently there is more than one context in your project (Web.Infrastructure.DepartmentDb and Web.Models.UsersContext) and migrations does not know for which of these migrations should be enabled. You need to point to the context type. As per the error message use:

Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb.

启用eManager.Web.Infrastructure.DepartmentDb或

to enable migrations for eManager.Web.Infrastructure.DepartmentDb or

Enable-Migrations -ContextTypeName eManager.Web.Models.UsersContext.

为eManager.Web.Models.UsersContext启用迁移

to enable migrations for eManager.Web.Models.UsersContext

这篇关于在程序包管理器控制台中运行enable-migrations时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆