You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I create a employee with DepartmentId & SubDepartmentId != null => Sucessfully !
When I create a employee with DepartmentId != null & SubDepartmentId = null => Failed with error:
(0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Employees_SubDepartments_SubDepartmentId".
The conflict occurred in database "rootTenantDb", table "SubDepartments", column 'Id'.
How to fix or work around it ???
public class Employee : AuditableEntity, IAggregateRoot
{
public string FirstName { get; private set; }
public string? LastName { get; private set;
.....
public DefaultIdType DepartmentId { get; private set; }
public virtual Department Department { get; private set; } = default!;
public DefaultIdType? SubDepartmentId { get; private set; }
public virtual SubDepartment SubDepartment { get; private set; } = default!;
}
public class SubDepartment : AuditableEntity, IAggregateRoot
{
public string Name { get; private set; } = default!;
public string Description { get; private set; } = string.Empty;
public DefaultIdType DepartmentId { get; private set; }
public virtual Department Department { get; private set; } = default!;
}
public class Department : AuditableEntity, IAggregateRoot
{
public string Name { get; private set; } = default!;
public string Description { get; private set; } = string.Empty;
}
At some tables, the system not add inner join
The text was updated successfully, but these errors were encountered: