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

Error "Type is enhanced..." when using same connection string in several prism modules

2 Answers 248 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Florian
Top achievements
Rank 1
Florian asked on 25 Jan 2013, 06:51 PM
Hi,

I am currently trying to incorporate OpenAccess into my (WPF) application. I am using several backends, one is a Sqlite database.
This sqlite database is accessed from several PRISM modules. All of the modules host their own (vertical architectured) functionality, including data model, view model, view, ...I have one OpenAccess model (fluent) within each PRISM module. My first approach was to share the connection to the sqlite backend (btw. i am only doing read-only access) through the app.config of the executable. This was the first time I encountered the "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." exception. Since I am not able to figure out what's wrong, I decided to share the connection string through my own configuration interface and passing it to the models on creation. Nevertheless, the exception still occurs. If I reduce my PRISM app using only one of the modules that use OpenAccess, everything is fine. Would you be so kind and tell me, how I can maintain my loosely coupled design ( I dont want to reference other modules for some kind of model sharing and I dont want a common DAL shared by my modules, since this would lead PRISM usage ad absurdum) and just share a connection string between different models accessing the same backend?
I am so far really happy with OpenAccess, since it beats EF in so many ways. I am sure, you know, what I am doing wrong.

Thanks in advance
Florian

2 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 30 Jan 2013, 09:28 AM
Hello Florian, 

The problem is that you are providing the same connection string key for different models and this error occurs because Open Access caches the metadata after the first OpenAccessContext is created. And after that if you use the context for objects which are not contained in the cashed metadata, the exception would be thrown.

There are two possible solutions:
1. Use different connection strings for any model you have. When you create new RLINQ file using the Add Domain Model Wizard, you should add a new connection string to the web.config/app.config for every new model.
2. Use AggregateMetadataSource to merge the metadata of two different context instances that use the same connection string. It can be implemented following this guide.

I hope that helps. If any other questions arise, do not hesitate to contact us.

Regards,
Boris Georgiev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Florian
Top achievements
Rank 1
answered on 30 Jan 2013, 10:27 AM
Hi Boris,

thanks for your answer. So, as I understand, the connection string is effectively used as a key to an internal cache of OpenAccess (maybe you could change that some day to use a different key, since the problem would be immediately gone then, right?). I try to think loud about your solutions in my case.

1. If I have a prism module that acts as a extension (think: plugin) to my application, it is not deployed with the application, but maybe added later. Therefore I cannot add an additional connectionstring to the app.config, since I don't know the plugin in advance (maybe it gets developed in 2014). Making the module add its own connection string to the app.config may work however (kind of little workaround, but I could integrate this cleanly).

2. Merging metadata may be a real option, nevertheless it will also require a given module to support it (by e.g. providing its metadata source to the aggregator or sth. similar).

Both solutions require additional implementation in my modules. That's not ideal, but I can live with that. I will see, which option fits
better.

As a sidenote: one of my backends is sqlite (and I have some non-trivial views in there). EF wasn't even able to create a model from those views. OpenAccess was able, nevertheless it needed some tweaking with regard to the inferred database types (most of them have been inferred as decimal), but I could solve it really easily.

Thanks for your help and a great free product.


Tags
Data Access Free Edition
Asked by
Florian
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Florian
Top achievements
Rank 1
Share this question
or