I have a class method GetMS()
as defined below, but when the method is called I get an error stating \'SLRD\' has no parameterless constructor.
I don\'
I don't understand why a parameterless constructor is even being called.
My guess is that you are populating ChildRequests
lazily via a Linq/EF query, so the objects are not created until you iterate over them (which is done as part of the First
method). At that point, EF tries to create an instance using a parameterless constructor which does not exist.
The error you get is pretty clear. You missed to define a parameterless constructor.
public class SLR : BaseEntity
{
public SLR() : base
{
}
// ...
public virtual ICollection<SLRD> ChildRequests { get; set; }
}
The reason this is happens is the fact that your base class may have a parameterless constructor. So you have to define one for the derived class, SLR
.