Creating a non mapped property in an entity (entity framework)

前端 未结 4 2089
[愿得一人]
[愿得一人] 2020-12-09 07:32

I want to create a custom property on one of my entities mapped from the database, however this property is not mapped to the database, I created the property using partial

4条回答
  •  旧巷少年郎
    2020-12-09 08:10

    This page really helped me. I'll add exactly what I added to my mapping configuration after seeing Kniganapolke's answer.

     public TheObjectName()
       {
           this.HasKey(t => t.ID);
           this.Ignore(t => t.IsProcess); //we don't want EF to worry about this
        }
    

    Thanks everyone, thanks SO!

提交回复
热议问题