Click here to Skip to main content
16,020,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys

So far I think I have tried every trick on the net.

I got this error this weekend "The underlying provider failed on Open." when trying to access EntityFramework in my local machine.

This is my connection string that was created automaticaly when creating EF

XML
<add name="dbPropertyManagerEntities" connectionString="metadata=res://*/PropSoftModel.csdl|res://*/PropSoftModel.ssdl|res://*/PropSoftModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\dbPropertyManager.mdf;integrated security=True;connect timeout=30;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />



Now this is my code to access the EF
C#
using (var context = new dbPropertyManagerEntities())
           {
               var query = from row in context.tbl_Property
                           select row;

               if (!string.IsNullOrEmpty(searchTerm))
               {
                   query = query.Where(row => row.propName.Contains(searchTerm) || row.propAddress.Contains(searchTerm));
               }
               query = query.OrderBy(s => s.propName);

               var qRowCount = query.Count();//Error is here
               var qRow = query.Skip(skip).Take(take);

               rowCount = qRowCount;

               return qRow.ToList();
           }
Posted
Updated 6-Apr-16 22:14pm
Comments
Jameel VM 9-Sep-13 4:41am    
the exception is because of invalid connection string.Please make sure that it's a valid connectionstring.

It may occurs due to connection string problem

just delete the model and take update it .

sometimes there was change make in database and we not update the model.






Ravi Halvadiya

www.InsightSoftech.com
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900