Efcore: Where is WithMany()?

Created on 4 Apr 2017  路  2Comments  路  Source: dotnet/efcore

I'm trying to create a many-to-many mapping with a junction table where I don't model the associative entity. Here is some code:

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

builder.HasMany(p => p.Roles).WithMany().Map(m =>
{
    m.ToTable("WorkflowStateRoles");
    m.MapLeftKey("WorkflowStateId");
    m.MapRightKey("RoleId");
});

WithMany() is no where to be found. What namespace do I need to include?

closed-duplicate

Most helpful comment

@ajcvickers Thanks for your reply. That's awful, though. Please prioritize as having to create entities, configurations, etc. isn't great and accessing the data through an extra layer is more nasty.

All 2 comments

Currently in EF Core many-to-many associates require the junction table to be mapped. See #1368

@ajcvickers Thanks for your reply. That's awful, though. Please prioritize as having to create entities, configurations, etc. isn't great and accessing the data through an extra layer is more nasty.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matteocontrini picture matteocontrini  路  88Comments

rowanmiller picture rowanmiller  路  112Comments

rowanmiller picture rowanmiller  路  101Comments

obelixA picture obelixA  路  105Comments

divega picture divega  路  146Comments