This project is read-only.

Web.config - connectionString

Nov 25, 2011 at 9: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:-


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 11:45 PM

OK Solved:-

 <add name="catEntities" connectionString="metadata=&quot;res://, Version=, Culture=neutral, PublicKeyToken=null/|res://, Version=, Culture=neutral, PublicKeyToken=null/|res://, Version=, Culture=neutral, PublicKeyToken=null/;;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 8: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 3: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.