I saw a number of related questions but none of them is exactly what I am looking for.
We are using one database and need to have separated edmx files, with different Model and ObjectContext class names. This results in having multiple connections string, which are different only in metadata part.
For now I ended up doing this:
Web.config
<connectionStrings configSource="connectionStrings.config"></connectionStrings>
connectionStrings.config
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Entity.Model.csdl|
res://*/Entity.Model.ssdl|res://*/Entity.Model.msl;
provider=CONNECTION STRING DATA GOES HERE"/>
<add name="TwoEntities" connectionString="metadata=res://*/TwoEntity.TwoModel.csdl|
res://*/TwoEntity.TwoModel.ssdl|res://*/TwoEntity.TwoModel.msl;
provider=EXACTLY THE SAME CONNECTION STRING DATA GOES HERE"/>
</connectionStrings>
In my ObjectContext derived classes I do have the default generated constructors:
public Entities()
: base("name=Entities", "Entities")
{
}
and
public TwoEntities()
: base("name=TwoEntities", "TwoEntities")
{
}
What would be very nice is not to have two connection strings in .config file, but share the same connection sting from this file and somehow override the metadata part of it in each class.
Any suggestions on how to do this?