Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

linq2db bulkcopyasync without error but no data inserted in the database

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?

question from:https://stackoverflow.com/questions/65932701/linq2db-bulkcopyasync-without-error-but-no-data-inserted-in-the-database

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...