2

I have a database with tables for users and roles. The relationship between them is many-to-many and I have a junction table UserRole.

I use Entity Framework to map this to my object model using this configuration:

 modelBuilder.Entity<User>()
            .HasMany(u => u.Roles)
            .WithMany(r => r.Users)
            .Map(m =>  m.ToTable("UserRole")
                          .MapLeftKey("UserId")
                          .MapRightKey("RoleId"));

This works as expected but now I need to expose this to Excel using OData and Powerpivot. But since the relationships are lost when imported into Powerpivot I also need to expose the junction table so that I can recreate the relationship inside Powerpivot.

I understand that I need to create a new entity, UserRole but I am not sure how to configure the mapping.

Does anyone have any suggestions?

RobinHu
  • 374
  • 2
  • 14

0 Answers0