问题
I am using linq2db
.NET Core library to bulk insert a collection. This code can be executed without error but there is no data in the database. There are 2000 person object in persons list object. Person object has already identity in it.
using (var db = SqlServerTools.CreateDataConnection(connstring)
{
await db.BulkCopyAsync(new BulkCopyOptions { KeepIdentity = true, TableName = "[Persons].[Person]" }, persons);
}
Person
table in in Persons
schema.
I have also tried with BulkCopy
which can be executed without exception but still nothing in the database.
Some troubleshooting done:
- If my table is without any schema, it works. I can execute without exception and in the database I can see the data.
- But if my table is with schema, I can execute it without exception but in the database, I cannot see the data.
Model with Schema
[Table("Person", Schema = "Persons")]
public partial class Person
{
[Key]
public int Id { get; set; }
}
Model without Schema
[Table("Person")]
public partial class Person
{
[Key]
public int Id { get; set; }
}
What have I miss out? How to troubleshoot further?
来源:https://stackoverflow.com/questions/65932701/linq2db-bulkcopyasync-without-error-but-no-data-inserted-in-the-database