I\'m sure I\'ve done this before at some stage, but I can\'t figure out how to now! My scenario:
// This is generated from EDMX
public partial class HOLDbEnt
I used the string interpolations feature of C# 6 in the .tt
code generation file.
The generated code becomes
public MyEntities()
: base($"name={MyConfigurationManager.ConnectionStringKey("MyEntities")}")
{
}
when you use
public <#=code.Escape(container)#>()
: base($"name={MyConfigurationManager.ConnectionStringKey("<#=container.Name#>")}")
in the .tt
file.
public static string ConnectionStringKey(string key)
in static class MyConfigurationManager
in my case adds the initials of the login to the key and checks whether any connection string in ConfigurationManager.ConnectionStrings
has that key in which case that key is returned and otherwise just returns the default key.
So now the connectionstring may be different per-user.
E.g.
means that user F.B. uses the latter key while all others the former key.