Modify SSDL runtime for ADO.NET and Entity Framewo

2019-08-03 05:56发布

问题:

I would like to undertand how to modify on fly the SSDL in a connection string.

I have followed the tutorial here: http://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov , but I am still not able to understand how to configure the "res://" line and where to put the .ssdl file.

I have a complex hierarchical structure to be compiance to an adapter structure:

<project root> 
    / Toolkit 
        / Database 
            / External 
                / Adapter 
                    / Abstract.cs
                    / File
                        / File.ssdl
                        / Adapter_File.cs
                    / MySql
                        / MySql.ssdl
                        / Adapter_MySql.cs
    [... and so on]

Into my Adapter_(database_type).cs I have the following code (this is for MySql:

    string conn =
              @"metadata=res://*/Toolkit.Database.External.ADO.ADODatabase.csdl" +
              @"|res://*/Toolkit.Database.External.Adapter.MySql.MySql.ssdl" +
              @"|res://*/Toolkit.Database.External.ADO.ADODatabase.msl;" +
              @"provider=MySql.Data.MySqlClient;" +
              "provider connection string=\"server=" + dbBean.Server + ";" +
              "Port=" + dbBean.Port + ";" +
              "User Id=" + dbBean.Username + ";"+
              "Password=" + dbBean.Password + ";" +
              "database=" + dbBean.Schema + "\"";

Everything seems to work fine, but runtime my application returns an error trying to connect to each database, it seems to not to reach the .ssdl file...

Any ideas? Thank you!