Entity Framework code first: How to ignore classes

后端 未结 2 1870
北荒
北荒 2020-12-15 22:56

This is similar to questions here and here, but those are old and have no good answers.

Let\'s say I have the following classes:

class HairCutStyle {         


        
2条回答
  •  渐次进展
    2020-12-15 23:34

    There are three things to ensure:

    1. Make sure you do not expose a DbSet in your DbContext-derived class
    2. Make sure you do not have any mention of HairCutStyle in your OnModelCreating override
    3. Mark your HairCutStyle property using the NotMapped attribute.

提交回复
热议问题