by JBrooks
9. November 2011 07:24
On one project we keep our connection string as an AppSetting (See: HERE). So that is what I use to build my RIA Services connection string to account for the differences between Dev, Test, QA and Prod. You could also do the same with a regularly stored connection sting. Here is how we did it:
public partial class MyDomainService
{
protected override MyEntities CreateObjectContext()
{
string ConnString = Common.cApp.AppSettings["DefaultConnection"];
string seConn = ConfigurationManager.ConnectionStrings["MyEntities"].ToString();
EntityConnectionStringBuilder ecsb = new EntityConnectionStringBuilder(seConn);
ecsb.ProviderConnectionString = ConnString;
EntityConnection ec = new EntityConnection(ecsb.ToString());
ScheduleEntities ctx = new ScheduleEntities(ec);
return ctx;
}
}
53793326-9fee-447e-8b15-7387cbb98345|0|.0|27604f05-86ad-47ef-9e05-950bb762570c
Tags:
Silverlight