Inherits from DbSet with the purposes to add property

后端 未结 4 566
太阳男子
太阳男子 2021-01-01 02:03

Is there a way to inherits from DbSet? I want to add some new properties, like this:

public class PersonSet : DbSet
{
    public int MyProperty         


        
4条回答
  •  长发绾君心
    2021-01-01 02:20

    I solved this using another variable to instantiate the "regular" DbSet.

        private DbSet _persons { get; set; }
        public PersonDbSet Persons { get { return new PersonDbSet(_persons); } }
    

    This way entityframework recognizes the Entity but I can still use my own DbSet class.

提交回复
热议问题