Auto generated class by EntityFramework 6.1:
public partial class STUDENT
{
public STUDENT()
{
this.STUDENT_GROUPS = new HashSet<STUDENT_GROUPS>();
}
public int ID { get; set; }
public int PERSON { get; set; }
...
public virtual ICollection<STUDENT_GROUPS> STUDENT_GROUPS { get; set; }
...
}
And STUDENT_GROUPS:
public partial class STUDENT_GROUPS
{
public int ID { get; set; }
public int GROUPS_GRP { get; set; }
public int STUDENT { get; set; }
public virtual STUDENT STUDENT1 { get; set; }
public virtual GROUPS_GRP GROUPS_GRP1 { get; set; }
}
Throws a CA2214: Do not call overridable methods in constructors, but since this is an autogenerated code, I think I am not supposed to change it, how should i approach this scenario? Thanks in advance
The code you have posted is not throwing an error, it is just violating a code analysis rule and will work fine. The generated code is correct and by design to allow for lazy loading. You should suppress that warning for those files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With