When a column is "ValueGeneratedOnAdd", it appears that linqtodb maps it as an identity column by default, but I believe it should instead be using [columnmetadata].GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.IdentityColumn to determine if the column is an identity column.
modelBuilder statement:
var pendingChangesCompanyKey = modelBuilder.Entity<ProductPrice>().Property(x => x.PendingChangesCompanyKey);
pendingChangesCompanyKey.HasComputedColumnSql($"ISNULL({nameof(ProductPrice.PendingChangesCompanyId)}, -1) PERSISTED").ValueGeneratedOnAdd();
linqtodb call:
var mergeTable = await Db.CreateLinqToDbConnection().CreateTempTableAsync<ProductPrice>("ProductPriceMerge", changedPrices);
generated sql:
CREATE TABLE [inventory].[#ProductPriceMerge]
(
[PriceCatalogId] int NOT NULL,
[StartDateUtc] datetime2 NULL,
[EndDateUtc] datetime2 NULL,
[IsFixedPrice] bit NOT NULL,
[BusinessCustomerId] int NULL,
[PendingChangesCompanyId] int NULL,
[PendingChangesCompanyKey] int NOT NULL IDENTITY,
[Psin] int NOT NULL,
[AcquisitionCost] decimal(18,2) NOT NULL,
[ListPrice] decimal(18,2) NOT NULL,
[SalePrice] decimal(18,2) NOT NULL,
[OverbillingPrice] decimal(18,2) NOT NULL,
[PriceEngineLog] nvarchar(max) NULL,
CONSTRAINT [PK_ProductPriceMerge] PRIMARY KEY CLUSTERED ([PendingChangesCompanyKey], [Psin], [PriceCatalogId])
)
When a column is "ValueGeneratedOnAdd", it appears that linqtodb maps it as an identity column by default, but I believe it should instead be using [columnmetadata].GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.IdentityColumn to determine if the column is an identity column.
modelBuilder statement:
linqtodb call:
generated sql:
linqtodb version 3.10.0