We are using ASP.NET Zero v11 and we're running into an issue where the CreatorUserId is not being filled in.
The application doesn't use the service classes for its custom work. The entities inherit from FullAuditedEntity which includes CreatorUserId. In our code, we create such an entity using a mapping from a view model. In the below code, Statement is an entity that inherits from FullAuditedEntity. IStatementRepository gets injected. private readonly IStatementRepository _repoStatement;
var theEntity = _objectMapper.Map(model);
theEntity.Statement = model.Statement.CleanHtml();
await _repoStatement.InsertAsync(witnessStatementEntity);
The repo:
public interface IStatementRepository : IRepository<Statement, Guid>
{
}
<br>
public classStatementRepository : OE_TenantRepositoryBase<Statement, Guid>, IStatementRepository
{
public StatementRepository(IDbContextProvider<OE_TenantDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
<br/> In an old(er) version of the codebase, so based on an older version of ASP.NET Zero, without setting the value for the CreatorUserId, this seemed to work fine and so the framework set this value automatically. However, in the current version, this seems not to be the case anymore.
We can set the value manually before calling the insert on the repo but if the entity inherits from FullAuditedEntity, shouldn't this value be set automatically by the framework? If so (which it's not doing right now), can this be enabled somehow?
3 Answer(s)
-
0
Hi @outdoored
Is this code called in an AppService or in a background job ?
-
0
This code is used directly in this case in the controller.
-
0