How to connection multiple connection string (runtime)

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
nattaporn
Posts: 3
Joined: Tue 04 Aug 2015 18:17

How to connection multiple connection string (runtime)

Post by nattaporn » Tue 04 Aug 2015 18:30

1. use entity framework 6.1.3 / Devart version 8.3.264.4
2. use entity framework => Dbcontext / database first
3. I try change connection string use

var mysqlBuilder = new Devart.Data.MySql.MySqlConnectionStringBuilder();
mysqlBuilder.UserId = "****";
mysqlBuilder.Password = "******";
mysqlBuilder.Database = "developer";
mysqlBuilder.Host = "localhost";
mysqlBuilder.Port = ****;
mysqlBuilder.PersistSecurityInfo = true;
string providerString = mysqlBuilder.ToString();

var entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.Provider = "Devart.Data.MySql";
entityBuilder.Metadata = @"res://*/Entities.DataModelEntities.csdl|res://*/Entities.DataModelEntities.ssdl|res://*/Entities.DataModelEntities.msl";
entityBuilder.ProviderConnectionString = providerString;

var uow = new DbContext(entityBuilder.ConnectionString);


database not change connection string use old database. how to change connection string run time.

Please help me
Thank you.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connection multiple connection string (runtime)

Post by Shalex » Wed 05 Aug 2015 10:16

Your code looks to be correct. Why had you decided that current connection string was not changed? Please enable the dbMonitor tool to trace the database activity of your application. This should help to localize the issue.

It's more likely that there is the Schema attribute in the storage part of your model which is targeting to old database (you can check this via dbMonitor). If so, remove the Schema="xxx" attributes from your SSDL. This can be done in design time of Entity Developer.
As an alternative, it is possible to leave the schema name in *.edml file, but to turn off the generation of the schema name in run-time queries using the IgnoreSchemaName option of EF-provider configuration: http://blog.devart.com/new-features-of- ... orkarounds.

nattaporn
Posts: 3
Joined: Tue 04 Aug 2015 18:17

Re: How to connection multiple connection string (runtime)

Post by nattaporn » Fri 28 Aug 2015 01:56

Thank you for answer but i know about problem.
1. The solution click right file .edml and choose model setting.
2. uncheck Preserve schema name in storage.
3. Recreate Model can change database

Post Reply