Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it mandatory to use Guid for Id in entity or aggregate? #33

Open
maulik-modi opened this issue May 5, 2021 · 1 comment
Open

Is it mandatory to use Guid for Id in entity or aggregate? #33

maulik-modi opened this issue May 5, 2021 · 1 comment

Comments

@maulik-modi
Copy link

maulik-modi commented May 5, 2021

hello @kgrzybek ,

We have learned in the past that searching based on Guid primary key is less performant as compared to Sequential Integer/Long primary key.

Is there any work around so we can get the best of both worlds - leverage Outbox for gurantee and search friendly primary key?
Is it possible to do like this in command handler?

I am thinking to have 3 methods in UnitOfWork

  1. SaveChanges - to flush entity changes - explicit call in command handler and fetch Primary Key
  2. BeginTransaction - to start database transaction - from decorator
  3. Commit - to commit transaction - from decorator

REference: https://entityframeworkcore.com/saving-data-transaction
Commit method can Invoke DomainEventDispatcher which in turn can record DomainEventNotifications in Outbox table.

Open for other ideas?

@dbeylkhanov
Copy link

dbeylkhanov commented Jan 8, 2022

@maulik-modi

Is it mandatory to use Guid for Id in entity or aggregate?

no, it's not. I'd rather say that using Guid is simplifying work with UoW within DDD

check out my pet project for generating strongly typed entity's id before saving changes into DB
https://github.com/beylkhanovdamir/StronglyTypedIdentity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants