0

I'm trying to implement basic three tier architecture with mvc 3. but getting an error while running the solution ( showing no error while building the solution). The organization of my projects & error message can be seen in the attached image.enter image description here

Please help.

OK guys, This is an update for.

As specified by some comments, I copied the original connection string from app.config to my web.config file & getting this error as shown in the image. enter image description here

I tried to search a lot but no clue! Any help will be highly appropriated.

Badhon Jain
  • 197
  • 1
  • 12

4 Answers4

1

The connection string you've copied is a normal connection string. You are using an edmx file which means you need an entity-connection string.

You need to copy the entity-connectionstring into the web.config. You can find the EF-connectionstring in the app.config file in the Data layer where EF added it for you.

Maarten
  • 22,527
  • 3
  • 47
  • 68
  • The primary problem is solved now, but still having some trouble with passing the data to the view! But that is another issue! Thanks. – Badhon Jain Oct 02 '12 at 09:10
1

@Maarten is right. you always copied the normal connection string (that is a part of entity-connection string). you need to copy the entire connection string that was generated in your App.config file in Data layer and paste it in the web.config file in your presentation layer. the entity-connection string like as :

<add name="NorthwindEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=Northwind;persist security info=True;user id=sa;password=Blister01;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

don't copy-paste it, it is just a sample

Tasnim Reza
  • 6,058
  • 3
  • 25
  • 30
  • The primary problem is solved now, but still having some trouble with passing the data to the view! But that is another issue! Thanks. – Badhon Jain Oct 02 '12 at 09:10
0

you just add connection string connectionStrings section in web.config in Presentation layer!

See this image

Sender
  • 6,660
  • 12
  • 47
  • 66
0

EDITED: try with this

<add name="NORTHWINDEntities" providerName="System.Data.SqlClient" connectionString="data source=(local)/sqlexpress; initial catalog=NORTHWND;Integrated Security=SSPI" />

laszlokiss88
  • 4,001
  • 3
  • 20
  • 26
  • Still not working. I used entity framework's database first model, while working on a single project, i never got any error like this, as far I can remember, I didn't had to use connection string! I'm getting this error while trying to synchronize three projects together. – Badhon Jain Oct 02 '12 at 07:15
  • Are you editing the web.config file in the project's root directory? http://stackoverflow.com/questions/517086/asp-net-mvc-and-two-web-config-files – laszlokiss88 Oct 02 '12 at 07:19
  • If so, try to remove the connection string from it. After that, remove your Entity Data Mode file(.edmx) and add generate it again from the database. (Probably this will solve your problem.) – laszlokiss88 Oct 02 '12 at 07:22