EF 4.1 Code First error - The entity type SomeType is not part of the model for the current context

后端 未结 10 1482
遇见更好的自我
遇见更好的自我 2020-12-10 00:28

While working with EF code first I get error given below at different times:

The entity type SomeType is not part of the model for the current context.

10条回答
  •  伪装坚强ぢ
    2020-12-10 01:03

    I got this when my class that inherited from DbContext did not declare the model as a property. For example, I neglected to add a property for FooModel in the code below:

    public class MyDBContext : DbContext
    {
        public DbSet FooModels{ get; set; }
    
        // etc. ... 
    }
    

提交回复
热议问题