© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
13 replies
Adnan307

❔ 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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Ef Core Unique Index Problem
C#CC# / help
3y ago
❔ ef core foreign key problem
C#CC# / help
4y ago
EF parameterless constructor
C#CC# / help
2y ago
EF Core
C#CC# / help
2y ago