Id value not retrieved when multi-column PK
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the F# example with the SillyTable schema against SQL Server, then trace the insert and generated-key retrieval path used by SubmitUpdates() for multi-column primary keys. Done means row.Id contains the database-generated identity value immediately after SubmitUpdates(), matching the value read back from the table.
Written by the indexing model from the issue text.
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
- Dominant language
- F#
- Stars
- 627
- Forks
- 147
- Avg merge
- 2h 2m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/SQLProvider
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
fsprojects/SQLProvider#872 · 2 comments ·
-
Repo Assist? Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 10/100
fsprojects/SQLProvider#870 · 1 comment ·
-
postgresql
Difficulty 4/5 3-5 days Newbie friendliness 58/100
fsprojects/SQLProvider#869 · 2 comments ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
fsprojects/SQLProvider#868 · 2 comments ·
-
sql server
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fsprojects/SQLProvider#851 · 1 comment ·