C
C#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.
A
Angius511d ago
Add a public parameterless constructor Or better yet, just remove the constructors you have and use required properties instead
A
adnan307511d ago
the problem is that i need the constructor because the class i inherit from is a nuget
A
adnan307511d ago
public constructor
A
adnan307511d ago
this means that it tries to call the constructor but i dont have parameters
A
Angius511d ago
Remove ctor from that class as well Or just add a public parameterless ctor, that should work as well
A
adnan307511d ago
the class i inherit from(nuget paket) is inheriting from another class... it wont work i need the constructor the picture above show an error when i add public parameterless ctor
A
Angius511d ago
One thing that comes to mind, is creating your own class that mirrors what the class from the nuget contains, use that class with EF, and just map between them as needed
A
Accord510d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ many to many database cant update the 3rd tablecant update the 3rd table who had the cust id and drink id✅ rest requests helphello i am trying to send to os command injections with RestSharp to dvwa for pentestering can someo❔ Source generator, generating type script definitions at compile timeI would like to make a automatic type script definition from code, i consider to use source generato❔ Making an async method without anything to async insidelet's say i have following scenario: ```csharp void Foo() { for(int i = 0 ; i < 10000000 ;i++){} /❔ Reading file from the folder where .csproj isHow can i read files from folder where .csproj is? just like webapps allow to do, they do not copy f✅ Interoperability between incompatible typesHi! I'm trying to pass a class back-and-forth from C# to CPP. This class contains some members that ❔ Set item to null inside a listHey! I am trying to remove some items from a JSON object (created like `var model = new ObjectModel{Refactoring long if statement that checks for user rolesHi, I'm trying to find a cleaner way of refactoring this if code block that checks for each user rol❔ IEnumerable and dependency injectionif i want to loop enumerable from DI multiple times ``` var foos = services.GetRequiredService<IEnum❔ How did you learn . NET ?Books /youtube/udemy /other courses, what resources made you learn .NET to use as your job as web de✅ Is it possible to disable these properties on EF6? Web API 2 project, multi-layered, NF472SCENARIO - Solution type is NET Framework 4.7.2 (it is, what it is). - I have this project, I'm cons✅ This EntityFramework query can not be translated for SQLiteThe issue lies within `Intersect`. The point of the query is to fetch the current user, and to popul✅ Detect Network RequestI want make service that detect all connection to specific domain or ip? And if this request contain❔ CORS errorHello, I have Cors error on my project. I add Addpolicy in my configureServices and also add app.Us❔ Ambiguities? How?Idk how i can resolve this i don't see the problem✅ How can I get rid of this annoying pointer thing in the first row, datagridview winforms^✅ How can I use a row header of a datagridview to display the row number instead of being empty?^✅ How can i properly display this datagridviewHow can i get rid of the row select thing on the left (just white space)✅ I am trying to output a 2D array to a datagridview, but it is not outputting correctlyIt is saying System.Int32[]✅ Task not returning and stopping programHey, I am currently trying to start one task for every string in the list, but this isn't working an