This is a migrated thread and some comments may be shown as answers.

[Solved] One database but persistence classes in two DLLs

1 Answer 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tomasz M.Lipiński
Top achievements
Rank 1
Tomasz M.Lipiński asked on 18 Oct 2011, 01:42 PM
Hi,
Let's discuss such an issue:
There are two applications. Both of them use different databases but with some tables that have exactly the same structure in both cases. Let it be the "Person" table. The persistent class for the Person table is the same for both cases and therefore I would like to keep it in a library and use this library in both applications. But each of them has its own tables, also; these tables must be defined in this application, apart from the library. And now: is it possible to do such tricks that would allow each of the applications to see its tables and the Person table as a single database, within a single scope? To refer from their tables / persistent classes directly to the Person table / class?

Regards
Tomasz

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 20 Oct 2011, 04:00 PM
Hello Tomasz M.LipiƄski,

I think this is partially possible. You will have to maintain three models - a base one (with the Person class, let's name it A) and two other which extend the base (B and C). Before you instantiate a context from the B or C models, you will have to merge their metadata with the metadata from model A, so that the Person class is accessible there. You can find more details about merging metadata from multiple models in this thread. However, defining associations between classes from different models will not be possible. 

The better and easier approach in this case would be to have two different models, which both contain the Person class (and the other base tables/classes). This would be the most stable solution, as you would not have to deal with any metadata manually and would be able to define all needed associations.
I hope that helps.

All the best,
Alexander
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

Tags
General Discussions
Asked by
Tomasz M.Lipiński
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or