Given a simple example scenario where we have two databases
that share some common tables, such as:
Publishing DB: Author, Book, User, Permission,
PermissionGroup
Law DB: Attorney, CourtCase, Plaintiff, User, Permission,
PermissionGroup
We want an assembly that manages user permissions which only
need access to the User, Permission and PermissionGroup tables. We would like this User focused assembly to
be common and shared in two separate Law and Publishing projects. This seems to indicate three separate models:
1. User model containing User, Permission,
PermissionGroup
2. Publishing model containing just Author and Book
(without User, etc.).
3. Law model containing just Attorney and CourtCase
(without User, etc.)
I understand that multiple models used in a single
EntityManager cannot contain duplicate entities, so the Law and Publishing models
could not contain User entities directly.
This implies a need to manually code navigation properties in
each of the Publishing and Law models to support navigation operations like Attorney.User.Permissions.
So, given the above, what are the best approach(s)
to take? Does Code First (or Code
Second) offer significant advantages? Could
I perhaps leverage PostSharp to inject User properties on any entity class that
has a UserID property as opposed to manual coding?
Or would it be more practical to just include User entities
in the Publishing and Law models directly and use a separate EntityManager when
working with User entities in the shared User assembly? That implies updates to three models when something changes with User, but maybe that is still the cleanest approach.
Thanks for any and all thoughts.