DbSet.Cast() Error: Cannot create a DbSet from a non-generic DbSet for objects of type 'Entity'

后端 未结 4 740
死守一世寂寞
死守一世寂寞 2021-01-02 15:22

Version Info:

I am using C# 4.5, Entity Framework 6.0, and MEF.

Code and Unit Test

I created a Test Project to expl

4条回答
  •  [愿得一人]
    2021-01-02 16:15

    Ok i know nothing about Entity framework but from looking at the docs

    http://msdn.microsoft.com/en-us/library/gg696521%28v=vs.103%29.aspx

    DbSet item = DbContext.Set;
    

    so actually your code would be the same as this:

    DbSet nonGeneric = context.Set();
    

    and to get a IUser

    DbSet nonGeneric = context.Set();
    

    or maybe

    var generic = nonGeneric.Cast>();
    

提交回复
热议问题