Base solution for your next web application
Open Closed

NotificationPublisher PublishAsync error : Can not set TenantId to 0 for IMustHaveTenant entities! #11832


User avatar
0
ricardo created

Hi, After updating to V13, NotificationPublisher is generating the following error:

ERROR 2024-01-11 16:07:23,657 [orker] Mvc.ExceptionHandling.AbpExceptionFilter - Can not set TenantId to 0 for IMustHaveTenant entities! Abp.AbpException: Can not set TenantId to 0 for IMustHaveTenant entities! at Abp.EntityFrameworkCore.AbpDbContext.CheckAndSetMustHaveTenantIdProperty(Object entityAsObj) at Abp.EntityFrameworkCore.AbpDbContext.ApplyAbpConceptsForAddedEntity(EntityEntry entry, Nullable1 userId, EntityChangeReport changeReport) at Abp.EntityFrameworkCore.AbpDbContext.ApplyAbpConcepts(EntityEntry entry, Nullable1 userId, EntityChangeReport changeReport) at Abp.EntityFrameworkCore.AbpDbContext.ApplyAbpConcepts() at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.SaveChangesAsync(CancellationToken cancellationToken) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesAsync() at Abp.Notifications.NotificationStore.<>c__DisplayClass14_0.<<InsertNotificationAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Abp.Domain.Uow.UnitOfWorkManagerExtensions.WithUnitOfWorkAsync(IUnitOfWorkManager manager, Func1 action, UnitOfWorkOptions options) at Abp.Notifications.NotificationStore.InsertNotificationAsync(NotificationInfo notification) at Abp.Notifications.NotificationPublisher.PublishAsync(String notificationName, NotificationData data, EntityIdentifier entityIdentifier, NotificationSeverity severity, UserIdentifier[] userIds, UserIdentifier[] excludedUserIds, Nullable`1[] tenantIds, Type[] targetNotifiers)

my code

public async Task SendSolicitacaoColaboradorMessageAsync(UserIdentifier user, string message, NotificationSeverity severidade) { await _notificationPublisher.PublishAsync(AppNotificationNames.SolicitacoesColaborador, new MessageNotificationData(message), severity: severidade, userIds: new[] { user } ); }

await _appNotifier.SendSolicitacaoColaboradorMessageAsync(new UserIdentifier((int)AbpSession.TenantId, userId), $"mesage {Solicitacao.DataInicial}", Abp.Notifications.NotificationSeverity.Success);


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Have you modified NotificationStore ?

  • User Avatar
    0
    ricardo created

    Hi,

    No.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ricardo

    Somehow, we don't get this error on non-modified project. Is it possible for you to share your project or a reproduction project via email with [email protected] ?