borisdj / EFCore.BulkExtensions

Entity Framework EF Core efcore Bulk Batch Extensions with BulkCopy in .Net for Insert Update Delete Read (CRUD), Truncate and SaveChanges operations on SQL Server, PostgreSQL, MySQL, SQLite
https://codis.tech/efcorebulk
Other
3.65k stars 582 forks source link

Bulk Insert failes on Geography type #181

Closed adamsosinski closed 5 years ago

adamsosinski commented 5 years ago

Hi,

I'm trying to use a bulk insert with spatial data in asp.net core 2.2 application. With the use of Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite extension It allows mapping IPoint type to Geography type in SQL Server DB for a single insert. But it throws the following exception when using the BulkExtension method:

The given value of type Point from the data source cannot be converted to type udt of the specified target column.

If it can be of any help, from SQL Server Profiler it looks like it is mapping geography column to varbinary(max) for a temporary table.

Not sure if I have missed something on the configuration for bulk insert or spatial support is not implemented.

Also below is my BulkConfig

_defaultBulkConfig = new BulkConfig
{
    PreserveInsertOrder = true,
    SetOutputIdentity = true,
    SqlBulkCopyOptions = System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints,
    TrackingEntities = true
};

I will really appreciate any assistance on this.

borisdj commented 5 years ago

Not yet supported. Duplicate of: Geometry , Geography #88

Anilkumarsingh2001 commented 4 years ago

not supported yet. I used a workaround by creating an intermediate table in destination database with Nvarchar(max) datatype.

miloszskalecki commented 3 years ago

I managed to implement a fix using TableInfo: https://github.com/borisdj/EFCore.BulkExtensions/issues/88#issuecomment-785884799