DapperLib / DapperLib/Dapper.Contrib

ExplicitKey vs Default constraint

Open
#94 0 comments 0 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

Hi there!

Few days ago I faced one issue.
I have table Users
(
[Id] uniqueidentifier NOT NULL DEFAULT (NEWID()),
PRIMARY KEY (Id)
)

And I have Model User.cs with [ExplicitKey] attribute on Id property

So here is funny thing... this ExplicitKey do nothing... Entity always created with new Id...
I don`t know is it normal behavior or not.... As I now Entity Framework has None Identity that allows using custom generated id
image

Thanks!

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 with the User.cs model and the SQL table definition in the issue, then trace how ExplicitKey is handled when an entity is inserted. Reproduce the NEWID() default-key case and compare the observed identifier behavior with the documented meaning of ExplicitKey; done should establish whether this is expected or define the required corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
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.