Entity Framework RC1 DbContext query issue

我怕爱的太早我们不能终老 提交于 2019-12-06 09:39:01

That is correct behavior. Plain DbContext has no idea about mappings (= doesn't know any of your entities). That is the reason why you should always create derived context. Your repository doesn't know about PlssContext but you can still inject it like:

public class Repository
{
  private readonly DbContext _context;

  public Repository(DbContext context)
  {
    _context = context;
  }
  ...
}

var repository = new Repository(new PlssContext());

You can't use base DbContext instance directly when using code first.

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