EF5.x with power tool 3.x Beta

I did the Reveres Eng inner code to generate the code first using the EF power tools for MYSQL database I am very good at reading tables. when i try to save anything i get below exception. I am not setting this field and I have nothing in my solution with this field name.

            ProjectContext db = new ProjectContext();
            Person person = new Person();
            person.UpdatedAt = DateTime.Now;
            person.UserId = 1;
            person.PersonName = "test";
            db.Persones.Add(person);

            db.SaveChanges();

{"Unknown column 'Discriminator' in 'field list'"}

      

EDIT I noticed that I had another class that inherited from this class

Open class Student: Person {

}

when i removed this inheritance it worked. but does anyone know why? any ideas?

+3


source to share


1 answer


The problem is that this field is automatically added when you have one class that inherits from another. This field is used so EF can know that the witch record represents Student and the witches only people.

This article mentioned by soadyp explains it better.



Models created with codefirst use TPH by default.

+4


source







All Articles