c# - Many to many relationship on same class not working -


i trying create many many relationship using efcore on same user class have based on entityframeworkcore.identityuser following instructions described here, here , here. have following user class:

public class myapplicationuser : identityuser {     public virtual icollection<myapplicationuserjunction> myapplicationusers { get; set; }     public virtual icollection<myapplicationuserjunction> managingmyapplicationusers { get; set; } } 

here joining table:

public class myapplicationuserjunction {     public int myapplicationuserid { get; set; }     public virtual myapplicationuser myapplicationuser { get; set; }     public int managedmyapplicationuserid { get; set; }     public virtual myapplicationuser managedmyapplicationuser { get; set; } } 

here onmodelconfiguring:

protected override void onmodelcreating(modelbuilder builder) {     base.onmodelcreating(builder);      builder.entity<myapplicationuserjunction>()         .haskey(uj => new { uj.managedmyapplicationuserid, uj.myapplicationuserid});      builder.entity<myapplicationuserjunction>()         .hasone(uj => uj.myapplicationuser)         .withmany(qu => qu.myapplicationusers)         .hasforeignkey(uj => uj.myapplicationuserid).ondelete(deletebehavior.restrict);      builder.entity<myapplicationuserjunction>()         .hasone(uj => uj.managedmyapplicationuser)         .withmany(qu => qu.managingmyapplicationusers)         .hasforeignkey(uj => uj.managedmyapplicationuserid); } 

whenever run efcore tools add migrations command, following error:

the relationship 'myapplicationuserjunction.myapplicationuser' 'myapplicationuser.myapplicationusers' foreign key properties {'myapplicationuserid' : int} cannot target primary key {'id' : string} because not compatible. configure principal key or set of compatible foreign key properties relationship.

i using entityframeworkcore.tools.dotnet package 1.0.0-preview3-final.

i have tried using single navigation property on user class, , i've tried not specifying withmany function described here no success.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -