DapperLib / DapperLib/Dapper.Contrib

ExplicitKey value is occasionally null upon insert

Open
#52 14 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

Hey Guys!

Just wondering if you've experienced this issue before. We've been using dapper (1.50.0 now) for a while and it all works great but in the past couple of weeks we started seeing null values for explicit primary keys upon inserting objects. It happens randomly, sometimes for one insert but sometimes for all the inserts.

We added logging and the key property always has the value right before the insert but the insert still throws the primary key cannot be null exception. Recycling the app pool fixes it all the time so it might not be dapper related but something with the environment... still wondering if you've ever encountered something like this with Dapper.

Thank you in advance!

Rob

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the intermittent insert failure described for Dapper 1.50.0, comparing the explicit key value immediately before insertion with the database error. Check whether app-pool recycling changes the behavior; done means determining whether Dapper.Contrib or the environment causes the null primary key.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.