Quantcast
Channel: URF - Unit of Work & (extensible/generic) Repositories Framework
Viewing all articles
Browse latest Browse all 1539

New Post: The entity type is not part of the model for the current context.

$
0
0
When I got this error I resolved it by creating an EntityTypeConfiguration for the model. It seems that is the only prerequisite to using the repository, you have to create one and then load it in the context.

public class MyTypeConfiguration : EntityTypeConfiguration<Models.MyType>
{
        public MyTypeConfiguration()
        {
            ToTable("MyType");
        }
}
then put this in your context..
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
            base.OnModelCreating(modelBuilder);

            // model binding configurations
            modelBuilder.Configurations
                         .Add(new MyTypeConfiguration())
}

Viewing all articles
Browse latest Browse all 1539

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>