OnModelCreating: EntityTypeConfiguration: Issue with HasRequired Mapping in Version 2

Apr 10, 2014 at 10:25 AM
ApplicationDbContext : OnModelCreating:
//Just including this because I'm using this object
EntityTypeConfiguration<IdentityUserLogin> entityTypeConfiguration = modelBuilder.Entity<IdentityUserLogin>().HasKey((IdentityUserLogin l) => new
                    {
                        UserId = l.UserId,
                        LoginProvider = l.LoginProvider,
                        ProviderKey = l.ProviderKey
                    }).ToTable("AspNetUserLogins");            

//The important bit:
entityTypeConfiguration.HasRequired<ApplicationUser>((IdentityUserLogin u) => u.User);
In Identity version 1 this code worked just fine. After update to version 2, the "u.User" property is gone.

The IdentityUserLogin has the following properties now:
LoginProvider
ProviderKey
UserId

Can anyone help me figure out how to go about to set up the same relationship (probably using UserId) in version 2 as I had in version 1?
Developer
Apr 10, 2014 at 5:57 PM
Move the configuration on the ApplicationUser entity
EntityTypeConfiguration<ApplicationUser> entityTypeConfiguration = modelBuilder.Entity<ApplicationUser>()

entityTypeConfiguration.HasMany(u => u.Logins).WithRequired().HasForeignKey(ul => ul.UserId);

The configuration for the IdentityUserLogin can remain the same except the important bit statement.