Composite alternate unique key #698
Replies: 2 comments 3 replies
-
Please any clue on this issue. |
Beta Was this translation helpful? Give feedback.
-
You're gonna have to be more specific... maybe add some code snippets, actual error messages? The way brands are implemented now (and products as well for that matter), they already have a unique name per tenant using fluent validation rules: public CreateBrandRequestValidator(IReadRepository<Brand> repository, IStringLocalizer<CreateBrandRequestValidator> T) =>
RuleFor(p => p.Name)
.NotEmpty()
.MaximumLength(75)
.MustAsync(async (name, ct) => await repository.GetBySpecAsync(new BrandByNameSpec(name), ct) is null)
.WithMessage((_, name) => T["Brand {0} already Exists.", name]); The TenantId property is added and handled (using a queryfilter) automatically by finbuckle. Finbuckle does have some methods "AdjustKey", "AdjustIndexes", ... (see https://www.finbuckle.com/MultiTenant/Docs/v6.7.2/EFCore under "Keys and Indexes"), which might be what you're after? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have a case which I need to composite an alternate unique key
for example I need to combine the Brand entity alternate key (Name and TenantId) because i want the name for each brand to be unique in its tenant
I added the TenantId property to the Brand entity but when I am saving the new row the database gives me an error which say that the AK must not be null because the TenantId is not assigned.
Is this case possible to achieve, if so Can any one kindly please show mw how to solve this case.
Thank you very much for your help.
Beta Was this translation helpful? Give feedback.
All reactions