Serhat Koroglu

Serhat Koroglu

  • NA
  • 19
  • 12.8k

ApplicationUser is not part of the model for the context

Sep 14 2017 4:58 AM

I'm trying to put Asp.net identity context to a class library that provides data access using entity framework edmx.

But it gives an error such; The entity type ApplicationUser is not part of the model for the current context.

Here is db context class;

  1. public class ApplicationUser : IdentityUser  
  2.     {  
  3.         public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)  
  4.         {  
  5.             // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType  
  6.             var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);  
  7.             // Add custom user claims here  
  8.             return userIdentity;  
  9.         }  
  10.     }  
  11.   
  12.     public partial class AppDbContext : IdentityDbContext<ApplicationUser>  
  13.     {  
  14.         public AppDbContext ()  
  15.             : base("name=AppDbContext")  
  16.         {  
  17.         }  
  18.   
  19.         public static AppDbContext Create()  
  20.         {  
  21.             return new AppDbContext();  
  22.         }  
  23.   
  24.         protected override void OnModelCreating(DbModelBuilder modelBuilder)  
  25.         {  
  26.             throw new UnintentionalCodeFirstException();  
  27.         }  
  28.           
  29.     
  30.         //public virtual DbSet<AspNetRoles> AspNetRoles { get; set; }  
  31.         //public virtual DbSet<AspNetUserClaims> AspNetUserClaims { get; set; }  
  32.         //public virtual DbSet<AspNetUserLogins> AspNetUserLogins { get; set; }  
  33.         //public virtual DbSet<AspNetUsers> AspNetUsers { get; set; }  
  34.     }  
 

Answers (1)