BUG Changing Database Connection

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
luigisaggese
Posts: 17
Joined: Fri 04 Nov 2011 16:43
Location: Italia

BUG Changing Database Connection

Post by luigisaggese » Thu 10 Nov 2011 08:41

Hi,
I have developed an ASP.Net web application that uses dotConnect for MySQL v.6.50.214 and Framework 3.5.

I have a problem with my domain model.

I have two different Db (e.g. the first is called FirstDB,the second SecondDb).
When i create my domain model(using the FirstDb db), i have a .xml file which mapped all table, business object and view.

Now, if i want to change my connection string (in the Web.config) to use the SecondDb db without re-deploy my application,i have a problem; in the mapping file there is however the name FirstDb (then work on this) as like:
and not SecondDb, as i would.

So, can i have in my xml file the second db name, as : without re-deploy my application but just changing web.config file?
Can you suggest me any idea?

Thanks in advance

luigisaggese
Posts: 17
Joined: Fri 04 Nov 2011 16:43
Location: Italia

Post by luigisaggese » Mon 14 Nov 2011 10:31

Any news :(

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 14 Nov 2011 14:01

Sorry for the delay. By default, Entity Developer stores the schema name in the model mapping. This is done to support the case of using tables from different schemata in a single model.

To change this behaviour, please clear the 'Preserve schema name in storage' check box in the model settings (you will have to re-generate the model if table names are already saved with the database name).

Please tell us if this helps.

luigisaggese
Posts: 17
Joined: Fri 04 Nov 2011 16:43
Location: Italia

Post by luigisaggese » Mon 14 Nov 2011 16:53

I have done following step:

1) I've deleted my xml file from DataContext
2) Open my Model Explorer
3) Unchecked 'Preserve schema name in storage'
4) Save model

When i see my NEW xml file that is genereted, however i see references to db name as reported before.

Let me know about something wrong in my steps.
Thanx in advance.
LS

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 15 Nov 2011 15:03

The schema name is stored in the model file (i.e., in the .lqml one), that's why it is used in generated XML anyway. To remove the schema name from the model file, you can do either of the following:
- re-generate the model with the 'Preserve schema name in storage' option disabled;
- disable the 'Preserve schema' option and re-generate the model storage (e.g., run the 'Generate Database Script' wizard with the 'Regenerate Storage' option enabled);
- open the .lqml file in a text editor and auto-replace the entries like 'Table Name="[DbName].' with 'Table Name="'.

Please tell us if this helps.

luigisaggese
Posts: 17
Joined: Fri 04 Nov 2011 16:43
Location: Italia

Post by luigisaggese » Tue 15 Nov 2011 16:12

Thanks StanislavK,
that is ok for Table name reference; in fact when i re-generate the model storage [DbName].[TableName] is changed in just [TableName] as expected. :D

But it doesn't work for function references that is however in the format [DbName].[FunctionName]. :cry:

Thanks a lot.
Let me know if is a bug.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 16 Nov 2011 18:08

This is the expected behaviour. Generally, the 'Regenerate Storage' option is implemented for the model-first scenarios, and its purpose in such scenarios is to set proper names and types of database objects after the 'conceptual' side of the model is changed. Removing schema name from table mappings is a by-product of this behaviour. Actually, it wouldn't work if you changed the entity type names generated by default: in this case, table names would be generated based on the entity type names and would not be equal to the names of the actual tables available in the database.

As model-first is not an option for model methods (obviously, models have no information by which a stored procedure could be created in the database), stored procedures mapping is not modified when regenerating storage.

To make the method mappings schema-ignorant as well, please remove the methods already available in your model and re-generate them from the stored procedures.

Post Reply