So this is how I have solved:
1. Modified the App.config like:
<connectionstrings configsource="DatabaseConnectionDetails.config" />;
and this is DatabaseConnectionDetails.config:
<connectionstrings>
<add name="networkingEntities" connectionstring="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=lucian;password=lucian;persist security info=True;database=networking"" providername="System.Data.EntityClient" />
<add name="networkingEntitiesAdmin" connectionstring="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=lucian;persist security info=True;database=networking"" providername="System.Data.EntityClient" />
</connectionstrings>
*2.*Added a contructor with string parameter to Model1.Context.tt template:
public <#=code.Escape(container)#>(string myString)
: base(myString)
{
<#
if (!loader.IsLazyLoadingEnabled(container))
{
#>
this.Configuration.LazyLoadingEnabled = false;
<#
}
#>
}
*3.*get the connection string like this:
string str = ConfigurationManager.ConnectionStrings["networkingEntitiesAdmin"].ConnectionString;
*4.*And whenever I want to use the context , I use(for example):
networkingEntities net=new networkingEntities(str);
public List<utilizator> ListaUtilizatori()
{
var query = from u in net.utilizator
select u;
List<utilizator> users = new List<utilizator>();
try
{
users = query.ToList();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return users;
}
Now, I still have to discover how I encrypt the config files....
Thank you all for help...