No context type was found in the assembly

纵饮孤独 提交于 2019-11-30 07:53:54
Cavyn VonDeylen

I eventually found the answer in this question. Basically, in the Package Manager Console there's a "Default project" dropdown. You need to set this to the project that contains your EF context.

I found similar post: Enable Migrations with Context in Separate Assembly?

Example:

enable-migrations -ContextProjectName MyProject.DBContexts -contexttypename MyProject.DBContexts.MyContextName -Verbose

For whom who made this mistake like I did:

Your context class must inherits from DbContext, just like that:

public class DirectorRequestContext : DbContext
{
    public DbSet<DirectorRequest> DirectorRequests { get; set; }
}

Also happens if for some reason your class with the connection isn't in the project. So right click and 'add to project' sorts that out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!