I have used Inheritance in my edmx model. I get the above error when I call Save Changes. I also discovered that some of the entities make it to the db despite the error. Please how do one work with inherited entities. Sample code below.
Note that Person is the Base class of all entities except BusinessStudent which has student as base class
Administrator admin = new Administrator()
{
LastName = "The Name -" + DateTime.Now.Ticks.ToString(),
FirstName = "Fast Name -" + DateTime.Now.Ticks.ToString(),
AdminDate = DateTime.Now.Date,
};
Instructor teacher = new Instructor()
{
LastName = "De Name -" + DateTime.Now.Ticks.ToString(),
FirstName = "La Name -" + DateTime.Now.Ticks.ToString(),
HireDate = DateTime.Now.Date,
};
Student stud = new Student()
{
LastName = "sir Name -" + DateTime.Now.Ticks.ToString(),
FirstName = "for Name -" + DateTime.Now.Ticks.ToString(),
EnrolmentDate = DateTime.Now.Date,
Degree = "Framework 101",
Credits = 4.6
};
BusinessStudent bizStud = new BusinessStudent()
{
LastName = "As Name -" + DateTime.Now.Ticks.ToString(),
FirstName = "Vern Name -" + DateTime.Now.Ticks.ToString(),
EnrolmentDate = DateTime.Now.Date,
Degree = "Entity 101",
Descipline = "Admin",
BusinessCredit = 5.3,
Credits = 4.6
};
bizStud.EntityAspect.AddToManager();
teacher.EntityAspect.AddToManager();
admin.EntityAspect.AddToManager();
stud.EntityAspect.AddToManager();
db.SaveChanges(); //This line throws Object must implement IConvertible exception