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

How to solve column mapping/order problem?

Aug 21, 2014 at 7:05 PM
Edited Aug 21, 2014 at 7:06 PM

I'm using EF Code First with Fluent API configuration.

My objects are inherited from a base class and I have changed the order of columns to look more convenient in SQL Server.
Like this:
Property(x => x.LocalId).HasColumnOrder(1); // default order is 7
Property(x => x.GlobalId).HasColumnOrder(2); // default order is 8

Now I have a problem with BulkInsert because of column mapping mismatch: columns are passed to SqlBulkCopy in the order of inheritance (derived first, then base), but in SQL server they are in my own order. When I remove "HasColumnOrder(...)", everything works.

Is there any way to set column mappings in a proper way accessing either directly SqlBulkCopy.ColumnMappings or setting any option in BulkInsert extension?
Sep 19, 2014 at 9:09 AM

Maybe you can look at this link :

And create a custom provider in order to use it.