在EF4 winforms中,我有一个Datalayer,DomainClasses,UI和Test项目的解决方案。
测试项目使用与主项目不同的数据库。为测试数据库启用迁移
我有用UI的app.config中的连接字符串名称设置主连接字符串。 我在测试项目的app.config中使用相同的连接字符串名称设置了测试连接字符串。
我的背景被设置为使用连接字符串名称如下:
public class Context : DbContext
{
public Context()
: base("EFTest") // uses named connection string from app.config
{ }
public DbSet<Person> People { get; set; }
// etc
}
我可以使在数据层项目迁移。但是,当我尝试在测试项目中启用项目时出现错误:
PM> enable-migrations -ProjectName Test
No context type was found in the assembly 'Test'.
我在想什么?