I'm trying to create an ASP.NET MVC application, but have been struggling all day to even get a model from the database set up. The frustrating part is that the connection string was generated when I created the ADO.NET model from the database, and it doesn't like it.
The connection strings found in web.config:
<add name="DefaultConnection"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"
/>
<add name="DatabaseEntities"
connectionString="metadata=res://*/Models.DatabaseModels.csdl|res://*/Models.DatabaseModels.ssdl|res://*/Models.DatabaseModels.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Database.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient"
/>
Exception triggered at statement:
using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["DatabaseEntities"].ConnectionString))
{..}
'ArgumentException' Keyword not supported: 'metadata'.
SOLUTION: As LTMOD answered, I needed two connections in web.config, the initial SqlClient and the generated EntityClient connection. I needed to use the SqlClient connection string in the 'using' statement, as well as calling con.Open() in the block.