I am getting an exception when loading related objects in my db. I am loading all my MatchData
objects and I want to iterate them with a foreach.
The ob
The inner exception says it all:
The class 'Boonekamp.ClassCollection.PlayerData' has no parameterless constructor
Change your PlayerData
to:
[Obsolete("Only needed for serialization and materialization", true)]
public PlayerData() {}
public PlayerData(Player player)
{
}
This way, you do have a parameter-less constructor that Entity Framework will be able to use during initialization. Yet, you prevent using that constructor in code using the [Obsolete]
attribute.