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
CreatorId and TenantId not autofilled on creation in tenants #1360
Comments
You need to manually set the TenantId for your entity. |
Ok, but why? There is code in the abp/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs Line 112 in c621e7a
And here the abp/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs Line 166 in c621e7a
For debugging purposes I also checked if CurrentTenant is set and if the conditions inside the But it isn't. |
Did you inherit from AsyncCrudAppService.cs? If not, you should set it yourself. If you inherited, try to override TryToSetTenantId and debug to see it. protected override void TryToSetTenantId(TEntity entity)
{
var tenantId = CurrentTenant.Id;
if (!tenantId.HasValue)
{
return;
}
var propertyInfo = entity.GetType().GetProperty(nameof(IMultiTenant.TenantId));
if (propertyInfo != null && propertyInfo.GetSetMethod() != null)
{
propertyInfo.SetValue(entity, tenantId, null);
}
} |
I found the issue:
If it is ok I will create a PR with a test checking the bug and then fix it. |
@Silthus You are correct, welcome to contribute PR. |
I followed the tutorial and created my first own
FullAuditedAggregateRoot
entity namedParkingplace
. The entity also implementsIMultiTenant
to provide multi tenant support.I went ahead and created the matching Dtos and an AppService for the entity. But I have the problem that the
CreatorId
andTenantId
are not set automatically when I create the entity in a tenant.If I use the host (default) tenant the
CreatorId
ist set correctly. TheTenantId
remainsnull
which is expected.Do I need to configure the entity somewhere else?
The text was updated successfully, but these errors were encountered: