Many to Many Relationship using EF Core I've implemented Many-To-Many relationship and wonder if this is the optimal way for it. Since I do not have extensive EF Core experience I would love if someone with more experience could check it out.
Scenario:

Many users
Many organizations
User can belong to multiple organizations
Organization can hold multiple users

// Organization.cs
public class Organization
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public virtual IEnumerable&lt;OrganizationUser&gt; OrganizationUsers { get; set; }
}

// OrganizationUser.cs
public class OrganizationUser
{
    public Guid OrganizationId { get; set; }
    public virtual Organization Organization { get; set; }
    public Guid UserId { get; set; }
    public virtual User User { get; set; }

    public Role Role { get; set; }
}

public enum Role
{
    Owner,
    Admin,
    User
}


// User.cs
public class User
{
    public Guid Id { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public virtual IEnumerable&lt;OrganizationUser&gt; OrganizationUsers { get; set; }

    [NotMapped]
    public virtual IEnumerable&lt;UserOrganizationOutputDto&gt; Organizations
    {
        get
        {
            return OrganizationUsers.Select(x =&gt; new UserOrganizationOutputDto
            {
                Id = x.OrganizationId.ToString(),
                Name = x.Organization.Name,
                Role = x.Role
            });
        }
    }
}


// Database Context code that is related
modelBuilder.Entity&lt;Organization&gt;()
    .HasMany&lt;OrganizationUser&gt;()
    .WithOne(x =&gt; x.Organization);
modelBuilder.Entity&lt;User&gt;()
    .HasMany&lt;OrganizationUser&gt;()
    .WithOne(x =&gt; x.User);

modelBuilder.Entity&lt;OrganizationUser&gt;()
    .HasKey(x =&gt; new {x.OrganizationId, x.UserId});
modelBuilder.Entity&lt;OrganizationUser&gt;()
    .HasOne(x =&gt; x.User)
    .WithMany(x =&gt; x.OrganizationUsers)
    .HasForeignKey(x =&gt; x.UserId);
modelBuilder.Entity&lt;OrganizationUser&gt;()
    .HasOne(x =&gt; x.Organization)
    .WithMany(x =&gt; x.OrganizationUsers)
    .HasForeignKey(x =&gt; x.OrganizationId);

```
Couple of pointers. You are mixing data notation and fluent mapping.
replace NotMapped attribute with .Ignore fluent mapping.
Also I think its cleaner to move each entity into its own mapping config class using IEntityTypeConfiguration&lt;T&gt;
Dont mix DTO and entities like that. Best practice is to project your entities to DTOs.