I'm developing a system using .NET which will be used by multiple users. Because of that, I need to identify on the database which data belongs to each user. Explaining with an example, imagine I have the entity
Product. Then each user has its own products, and so in the database on the table of products we must be able to distinguish between products of each user.
Saying that, my solution was to add on the database an extra column for each table for the user id. Now, on my code this was the same as adding on my repositories a parameter to receive the id of the user so that the repository would be able to locate the correct data. The concrete implementation of the repository to deal with relational databases just check those columns.
The problem is that to be able to get those columns available on my repository, and on my ORM (in the case EF) I needed to add on each entity one property
UserID. The problem is that if I think for a while this doesn't seem like a good solution. I'm coupling domain entities with details of how to persist data. More than that, I'm coupling each entity with the way I manage the access to the data and this seems a bad approach.
So, concearning this, is there a better way to plan this? A way to make sure we can relate data to users and in the same time avoid those properties on the domain entities?