linq2db bulkcopyasync without error but no data inserted in the database

非 Y 不嫁゛ 提交于 2021-02-11 12:24:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!