Error: The type 'TEntity' must be a reference type
entity-framework, generics, reflection
Solution
Add generic constraint to your class declaration:
public partial class GridMastercontrol<TEntity> : UserControl where TEntity : class
You have to do that, because `ObjectSet<TEntity>` already has one:
public class ObjectSet<TEntity> : ObjectQuery<TEntity>,
IObjectSet<TEntity>, IQueryable<TEntity>, IEnumerable<TEntity>,
IQueryable, IEnumerable
where TEntity : class
Problem
``` public partial class GridMastercontrol<TEntity> : UserControl { private System.Data.Objects.ObjectSet<TEntity> _osMain; // error here } ``` I am unable to declare an object set of generic type. Please help me how to do that. The error message is- The type 'TEntity' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Objects.ObjectSet'