Open
Description
Description
When a record is inserted in a table that has a multi-column primary key, the Identity value generated is not retrieved.
Repro steps
- Create a silly table:
create table SillyTable (TenantId int not null, Id int identity not null)
alter table SillyTable add constraint PK_SillyTable primary key (TenantId, Id)
- Insert a row and get the value for Id
let testError () =
let ctx = sql.GetDataContext()
let row = ctx.Dbo.SillyTable.Create()
row.TenantId <- 1
ctx.SubmitUpdates()
let id = row.Id //always 0
let readRow = ctx.Dbo.SillyTable |> Seq.last
let readId = readRow.Id //return just inserted value (identity)
(id, readId) //readId has the expected value
Expected behavior
After SubmitUpdates(), the row.Id value should be updated with the value generated by the DB.
Actual behavior
The Id column keeps its default value (0 in this case) after SubmitUpdates()
Known workarounds
None
Related information
Operating System: Windows 10 Pro
Visual Studio: 2017 15.8.1
FSharp.Core 4.5.2
SqlProvider 1.1.48
DB: SqlLocalDB v13