I'm designing a multi-tenant Azure application using CodeFluent Entities and plan to use Identity columns on all tables and a GUID for the Tenant ID. I have read this article > https://dba.stackexchange.com/questions/98118/composite-primary-key-in-multi-tenant-sql-server-database and also this article > Best approach for multi-tenant primary keys. Has anyone done this using CodeFluent Entities?
Asked
Active
Viewed 77 times
1 Answers
-1
Using CodeFluent Entities, you can create a Tenant
entity and create a composite key on all entities:
<Tenant>
<Id key="true" typeName="guid" />
<Name />
</Tenant>
<Entity>
<Id key="true" typeName="int" persistenceIdentity="true" />
<Tenant key="true" typeName="Tenant" />
<OtherProperties />
</Entity>
If you have lots of entities, you can add the Tenant property using an aspect.

meziantou
- 20,589
- 7
- 64
- 83
-
I'm not sure I asked the right question. I understand about creating aspects ad have done this before. My question was (supposed to be) more about using CodeFluent Entities to generate SQL Azure multi-tenant structures. I know how to use CodeFluent to create schemas, I was looking for some more practical skills in terms of what's considered to be best practice regarding the use of composite keys in a multi-tenant environment and deploying continual database changes. Perhaps I should close this question and ask a better one? – May 04 '17 at 13:12
-
My answer was about creating a composite key with CodeFluent Entities (`key` attribute). However, I think you are looking for best practices to design your database for a multi-tenant scenario. In this case, you should ask a new question (not related to CodeFluent Entities). – meziantou May 04 '17 at 13:19