diff --git a/EFCore.BulkExtensions.Tests/BulkInsertOrUpdate/BulkInsertTests.cs b/EFCore.BulkExtensions.Tests/BulkInsertOrUpdate/BulkInsertTests.cs index f5d535e..59cc789 100644 --- a/EFCore.BulkExtensions.Tests/BulkInsertOrUpdate/BulkInsertTests.cs +++ b/EFCore.BulkExtensions.Tests/BulkInsertOrUpdate/BulkInsertTests.cs @@ -164,4 +164,39 @@ public async Task BulkInsert_AtypicalIds(DbServerType dbType) Assert.True(itemsFromDb.OrderBy(x => x.GuidProperty).Select(x => x.GuidProperty).SequenceEqual(items.OrderBy(x => x.GuidProperty).Select(x => x.GuidProperty))); } } + + [Theory] + [InlineData(DbServerType.SQLServer)] + [InlineData(DbServerType.SQLite)] + public void BulkInsert_CustomColumnNames(DbServerType dbType) + { + var item = new Entity_CustomColumnNames() + { + Id = 0, + CustomColumn = "Value1", + GuidProperty = Guid.NewGuid(), + }; + + var item2 = new Entity_CustomColumnNames() + { + Id = 0, + CustomColumn = "Value2", + GuidProperty = Guid.NewGuid(), + }; + + using (var db = _dbFixture.GetDb(dbType)) + { + var items = new[] { item, item2 }; + db.BulkInsert(items, c => + { + c.SetOutputIdentity = true; + }); + } + + using (var db = _dbFixture.GetDb(dbType)) + { + var insertedItem = db.EntityCustomColumnNames.Single(x => x.GuidProperty == item.GuidProperty); + Assert.Equal("Value1", insertedItem.CustomColumn); + } + } } diff --git a/EFCore.BulkExtensions/SqlAdapters/SQLite/SqLiteAdapter.cs b/EFCore.BulkExtensions/SqlAdapters/SQLite/SqLiteAdapter.cs index 06e32f2..4e546cb 100644 --- a/EFCore.BulkExtensions/SqlAdapters/SQLite/SqLiteAdapter.cs +++ b/EFCore.BulkExtensions/SqlAdapters/SQLite/SqLiteAdapter.cs @@ -403,7 +403,7 @@ internal static SqliteCommand GetSqliteCommand(DbContext context, Type? type, if (propertyEntityType != null) { - string? columnName = propertyEntityType.GetColumnName(tableInfo.ObjectIdentifier); + string columnName = propertyEntityType.Name; var propertyType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; //SqliteType(CpropertyType.Name): Text(String, Decimal, DateTime); Integer(Int16, Int32, Int64) Real(Float, Double) Blob(Guid)