Ignoring all properties but some in Entity Framework 6

前端 未结 2 967
醉话见心
醉话见心 2021-01-16 04:07

I want to persist some data on a database using Entity Framework.
I have some bigger POCOs but I want to store some of the properties only.

I know that I can a

2条回答
  •  一生所求
    2021-01-16 04:55

    You can mark individual properties as NotMapped within the class itself.

    public class MyPoco
    {
        public int Id { get; set; }
    
        [NotMapped]
        public string Name { get; set; }
    
        public int SomeSpecialId { get; set; }
    }
    

    Doesn't solve your issue of 'ignore everything but this' but might make it obvious what is and isn't included.

提交回复
热议问题