This project has moved and is read-only. For the latest updates, please go here.
1
Vote

Private classes derived from models cause errors

description

I found two separate errors.

When you have a private class somewhere nested in your code that derives from a model class that is mapped to a table, EF migrations will take notice of this and add columns to the table for each additional property that was specified in the private class, as well as a not-nullable "Discriminator" column. BulkInsert doesn't realize these columns and this creates invalid mappings. At this point BulkInsert stops working entirely, each call will throw an InvalidOperationException (Value cannot be null).

If you don't want EF to map your private subclass you can use the [NotMapped] attribute to make EF ignore it. This however creates another problem with BulkInsert. If you pass a collection that contains instances of such [NotMapped] subclass to BulkInsert it seems it's unable to determine which table should be inserted into, and throws a different exception.

comments