This error can be confusing:
1Cannot find the object "XXX" because it does not exist or you do not have permissions
It took me a while to profile queries and understand that the root cause was this statement:
1SET IDENTITY_INSERT "XXX" ON;
It was ORM-generated and was present only in particular cases which made debugging even harder. This is not obvious but
SET IDENTITY_INSERT command actually requires
INSERT is not enough for it.
A similar issue reported at StackOverflow