Web.config - connectionString

Nov 25, 2011 at 8:41 PM

Hi Guys - I hope someone can help.

I'm trying nHydrate vs my usual provider MS EF. Anyway as a trial I want to fill a grid with some data from one table - say customers in Northwind. I have created a solution and generated the EFDAL and EFDAL.Interfaces. IMPORTS the correct references and written a LINQ statment to return the table:-

Imports MyCompany.cat.EFDAL
Imports MyCompany.cat.EFDAL.Entity

Dim db As New catEntities

Dim allCustomers = _
From p In db.Customer _
Select p

gv.DataSource = allCustomers

But the above fails because there is no connection string in the Web.config.

How do I generate this connection string? Do I have to hand type it? I have tried this but no joy... Can anyone help create a simple project - I prefer VB Asp.Net, I which I can do the above from the Northwind DB.
If I can get this to work then I will be able to continue investigating this tool.

Thanks - Marcus

Nov 25, 2011 at 10:45 PM

OK Solved:-

 <add name="catEntities" connectionString="metadata=&quot;res://argos.cat.EFDAL, Version=, Culture=neutral, PublicKeyToken=null/argos.cat.EFDAL.cat.csdl|res://MyCompany.cat.EFDAL, Version=, Culture=neutral, PublicKeyToken=null/MyCompany.cat.EFDAL.cat.ssdl|res://MyCompany.cat.EFDAL, Version=, Culture=neutral, PublicKeyToken=null/MyCompany.cat.EFDAL.cat.msl&quot;;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;Initial Catalog=SimpleNHibernate;Integrated Security=True;Connection Timeout=60;multipleactiveresultsets=true&quot;" providerName="System.Data.EntityClient" />

Nov 29, 2011 at 7:08 PM

You cannot generate it. Just following the pattern below for EF.

<add name="MyProjectNameEntities" connectionString="metadata=res://*/MyCompanyName.MyProjectName.EFDAL.MyProjectName.csdl|res://*/MyCompanyName.MyProjectName.EFDAL.MyProjectName.ssdl|res://*/MyCompanyName.MyProjectName.EFDAL.MyProjectName.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=SSPI;Connection Timeout=60;multipleactiveresultsets=true&quot;" providerName="System.Data.EntityClient" />

May 10, 2012 at 2:55 PM

The newest version now allows you to use a normal connection string. There is no need to specify all the extra metadata anymore. You can use a normal connection string in the web.config file or in the Context's constructor.