I am running into an issue where users that are enforced by RLS can do everything except insert new records and they receive a DbUpdateConcurrencyException.
If the user is a part of a group not filtered by RLS, no issue occurs. This can be replicated by moving myself into a db role that gets successfully filtered, but I am unable to add new records to the table.
Here is my TVF:
ALTER FUNCTION [RLS].[tvf_AssignmentsSecurityPredicate](@RlsArea INT, @BrandID SMALLINT, @ASM INT)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN SELECT 1 AS tvf_securityPredicate_result
FROM RLS.AssignmentsRLS AS rls
WHERE (rls.Email = SUSER_SNAME() AND
(rls.AreaID = @RlsArea OR rls.BrandID = @BrandID OR rls.ASM = @ASM))
OR (IS_MEMBER('all_admin') = 1
OR IS_MEMBER('all_leadership') = 1
OR IS_MEMBER('concierge') = 1
OR IS_MEMBER('db_owner') = 1);
And the security policy:
ALTER SECURITY POLICY [RLS].[SecurityPolicies]
ADD FILTER PREDICATE [RLS].[tvf_AssignmentsSecurityPredicate]([RlsArea],[BrandID],[Retailer_ASM]) ON [dbo].[tblPairings]
WITH (STATE = ON, SCHEMABINDING = ON)
Any ideas?