I have ASP.NET MVC application with 2 separate databases. The first database is standard Identity context
public class ApplicationUser : IdentityUser {
public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager) {
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager) {
return Task.FromResult(GenerateUserIdentity(manager));
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> {
public ApplicationDbContext()
: base("ApplicationConnection", throwIfV1Schema: false) { }
public static ApplicationDbContext Create() {
return new ApplicationDbContext();
}
}
second context
public class TestModel : DbContext {
public TestModel()
: base("Connection") {
}
public virtual DbSet<A> As { get; set; }
public virtual DbSet<B> Bs { get; set; }
public virtual DbSet<C> Cs { get; set; }
}
I successfully enabled migration for TestModel and try to run
add-migration Initial -ConfigurationTypeName project.Migrations.TestMigrations.Configuration
which results in the error
One or more validation errors were detected during model generation:
project.Models.Tests.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
project.Models.Tests.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.
IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.
I was not able to find anything related to this problem and appreciate any help here. Thank you.