I'm trying to use Entity Framework but I keep getting the error "The underlying provider failed on Open.". I am storing the password within the code at the getConnectionString function provides a valid connection string and I know it works because I use that function throughout (albeit throughout my non-Entity Framework programs). I have Customer defined in my Model1 file. Customer is a database.
// gets valid connection string
string cs = getConnectionString();
var entityConnectionStringBuilder = new EntityConnectionStringBuilder();
entityConnectionStringBuilder.Provider = "System.Data.SqlClient";
entityConnectionStringBuilder.ProviderConnectionString = cs;
entityConnectionStringBuilder.Metadata = "res://*";
CUSTEntities1 CustContext = new CUSTEntities1(entityConnectionStringBuilder.ToString());
var q = (from i in CustContext.Customers
where i.CustLen == 15
select new CustomerClass
{
fid1 = i.fid1,
fid21 = i.fid2,
custlen = (int)i.CustLen
}).ToList<CustomerClass>();
I am new to Entity Framework and am trying to make a simple test app to help me understand it. Any help would be greatly appreciated. I have rebuilt the project from scratch to make sure that I had all the parts I needed for EF.