I have worked on a project with Code-first Approach and know I need to convert it to Database-first Approach, because I have some logic I have to executed it through Stored-Procedure.
So, I decided to Convert my Project from code-first to database-first
Anyhow, I have moved the identity tables to the new database.
I have got this Error,
The property 'Claims' on type 'AspNetUser' is not a navigation property. The Reference and Collection methods can only be used with navigation properties. Use the Property or ComplexProperty method.
and in the OnModelCreating I have added these lines
modelBuilder.Entity<AspNetUser>().ToTable("AspNetUsers");
modelBuilder.Entity<AspNetUserRole>().ToTable("AspNetUserRoles");
modelBuilder.Entity<AspNetRole>().ToTable("AspNetRoles");
modelBuilder.Entity<AspNetUserClaim>().ToTable("AspNetUserClaims");
modelBuilder.Entity<AspNetUserLogin>().ToTable("AspNetUserLogins");
modelBuilder.Entity<AspNetUser>().Property(r => r.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<AspNetRole>().Property(r => r.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<AspNetUserClaim>().Property(r => r.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
any Solution for that ?
Update (1)
When I change the connection string it gives me these errors
One or more validation errors were detected during model generation: AwesomeMvcDemo.Models.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType. AwesomeMvcDemo.Models.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType. IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined. IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.