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

Multiple Domain Models in Different Class Libraries Causing Probelms

1 Answer 56 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.
Michael
Top achievements
Rank 1
Michael asked on 21 Dec 2012, 06:40 PM
Hello,

I'm building an internal administration application and decided to give OpenAccess a try instead of using EntityFramework.

I'm using a MVVM approach and I have one project which contains my view and view-models.  I then I have three projects, one for each data context, containing a domain model for OpenAccess which make up my data layer.  While each domain model models a unique database these databases have some common tables which are identical across all of the databases (log table).

I have a view where a user is to be displayed various logs in the system.  I get a connection string from the user.  The connection string could be to any of these databases.  My assumption was to take the connection string and open a connection to each of the contexts and query for a table which was unique to that database; the theory being that only the context with the unique table would not fail the query.

This is how I imagined my design.  When I put it into practice I am getting an error from one of domain models:

Type is enhanced and registered, but not available from the database class meta data. This can be caused by a wrong connection id or configuration.

Now each domain model is in its own class library separated by assembly and namespace.  I have a connectionString node in my app.config, but the connection strings in the configuration are never used when this app is deployed.  They're just pointers to shell databases that I use for mapping my schema. When I first started troubleshooting this issue I found that having the same connection string may be the issue.  This doesn't seem to be the problem as I can comment out the checks for the other domains and provide a correct connection string that is for that domain and get the above issue. 

I've looked into the multiple domain sources link but this is for having the models in a single project.  I still attempted the suggestions leaving the domain models in their separate class libraries, but I'm still getting the error.

My thought is move to ADO.NET and run the analogous SQL command.  This would allow me to check without having to create a connection using OpenAccess but the problem still remains that if I detect the specific context that is giving me the error it still gives me an error even if I haven't attempted a connection to the other contexts.

Project Structure:
AdministratorApp: contains views and view-models
Product1DL: data layer for product one; contains a domain model (uniquely named) along with partial classes for the persistent classes
Product2DLdata layer for product two; contains a domain model (uniquely named) along with partial classes for the persistent classes
Product3DLdata layer for product three; contains a domain model (uniquely named) along with partial classes for the persistent classes

Is there something that I'm blatantly missing here?

Thanks,

Mike G.

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 26 Dec 2012, 01:37 PM
Hi Mike,

Working with more than one OpenAccess models that have different connection strings should not be a problem normally. Given the exception that you have received I have several questions for you:
  1. Do you reference from ProductXDL to ProductYDL?
  2. Have you extracted some of the common entity types into a separate assembly in order to reuse them?
  3. Are the domain models synchronized with the database schema? You said that you are creating your models based on a hollow database and later you test the code using the real one. If the two databases have different schemas that can lead to the problem that you have experienced.
Answering these questions will give us clues what is causing the problem. But if you have no cross references between Data Layer project, no common entities project and all you models and data base schemas are in sync, please try to isolate the failing code, package it with the model and the database schema and send it to us for further detailed analysis.

All the best,
Viktor Zhivkov
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or