I have an app that the connection string changes by per user and machine. that said I have made a test connection string just to get it testing. Then once that is working I will add the dynamic connection string.
After some research I have figured out that there is a problem with the connection string.
If someone could please tell me where I am wrong I would appreciate it.
var s = @"metadata=res://*/ProcurementModel.csdl|res://*/ProcurementModel.ssdl|
res://*/ProcurementModel.msl;provider=System.Data.SqlClient;
provider connection string=&';data source=JAMES-DESKTOP\SQLEXPRESS;initial catalog=MyDatabase;persist security info=True;user id=User;password=*****;MultipleActiveResultSets=True;App=EntityFramework&';";
Update:
public ProcurementContext()
{
var s =
@"metadata=res://*/ProcurementModel.csdl|res://*/ProcurementModel.ssdl|
res://*/ProcurementModel.msl;provider=System.Data.SqlClient;
provider connection string=&';data source=JAMES-DESKTOP\SQLEXPRESS;initial catalog=MyDatabase;persist security info=True;user id=jd;password=P@ssw0rd;MultipleActiveResultSets=True;App=EntityFramework&';";
_connectionString = s;
}
Getting data:
public List<Procurement> ParcelListByUser(string userName)
{
using (var context = new ProcurementEntities(_connectionString))
{
return context.Procurements.Where(p => p.UserName == userName).ToList();
}
}
Constructor:
public ProcurementEntities(string connectionString)
: base(connectionString)
{
}
Error message:
Format of the initialization string does not conform to specification starting at index 165.
Configuration:
The configuration of the Procurement
public class ProcurementConfiguration:DbConfiguration
{
public ProcurementConfiguration()
{
SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy());
SetDefaultConnectionFactory(new SqlConnectionFactory(ConnectionStrings.LocalConnectionString));
}
}
connection string=&';looks wrong. should probably be something likeconnection string="?