adnan307
adnan307
CC#
Created by adnan307 on 12/30/2022 in #help
❔ ef core foreign key problem
public class Player
{
public int Id { get; set; }
public Ban Ban { get; set; }
}

public class Ban
{
public int Id { get; set; }
public Player Player { get; set; }
public Player Admin { get; set; }
}
public class Player
{
public int Id { get; set; }
public Ban Ban { get; set; }
}

public class Ban
{
public int Id { get; set; }
public Player Player { get; set; }
public Player Admin { get; set; }
}
how i need to configure the foreign keys for this situation?
6 replies
CC#
Created by adnan307 on 12/10/2022 in #help
❔ Ef Core Constructor problem
Hello its my first big project with ef. I have an class with 3 attributes and one constructor that is calling the base constructor. My Class inherit from another class.
public class SPlayer : Player
{
public new int Id { get; set; }
public Account Account { get; set; }
public string Name { get; set; }

public SPlayer(ICore core, IntPtr nativePointer, ushort id) : base(core, nativePointer, id)
{

}
}
public class SPlayer : Player
{
public new int Id { get; set; }
public Account Account { get; set; }
public string Name { get; set; }

public SPlayer(ICore core, IntPtr nativePointer, ushort id) : base(core, nativePointer, id)
{

}
}
The problem is that ef core need an parameter less constructor. I tried to add an private constructor but its not working.
No suitable constructor was found for entity type 'SPlayer'. The following constructors had parameters that could not be bound to properties of the entity type:
Cannot bind 'core', 'nativePointer', 'id' in 'SPlayer(ICore core, IntPtr nativePointer, ushort id)'
Note that only mapped properties can be bound to constructor parameters. Navigations to related entities, including references to owned types, cannot be bound.
No suitable constructor was found for entity type 'SPlayer'. The following constructors had parameters that could not be bound to properties of the entity type:
Cannot bind 'core', 'nativePointer', 'id' in 'SPlayer(ICore core, IntPtr nativePointer, ushort id)'
Note that only mapped properties can be bound to constructor parameters. Navigations to related entities, including references to owned types, cannot be bound.
14 replies