Skip to content

InvalidCastException on bulk insert #42

Description

@v-echo

Hi,

Using the Nuget package EntityFramework6.BulkInsert, I'm trying to insert a collection of 200-300 items into a table and failing with the following exception:

System.InvalidCastException: 'Specified cast is not valid.'
Stack Trace: at EntityFramework.MappingAPI.Mappers.MapperBase.MapProperty(EntityMap entityMap, EdmProperty edmProperty, Int32& i, String& prefix)

The C# call is as follows:
ctx.BulkInsert(ds, ctx.Database.CurrentTransaction?.UnderlyingTransaction);
where ctx is a DbContext instance. There is an underlying transaction.

The table structure DSearch is simple:

public class DSearch
    {
        public Guid Id { get; set; }
        public string Match { get; set; }
        public int Distance { get; set; }
        public int Index { get; set; }
    }

Worth mentioning is that the PK on that table is composite, formed of all 4 properties/columns.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions