I have created a web application project(based on entity framework 5.0). Inside the solution that i created a entity data model inside a new .cs project based on version 5.0 . Now I have 2 web.configs(1 for web application project and another for entity data model project) in which I cannot access Entity class for webpage for which connection string is defined in web.config (inside the entity data model project).Now, Iam getting error as "No connection string could be found in the application config file". How to remove this problem?
Asked
Active
Viewed 721 times
0
-
1create a connection string in project's web.config – Vikas Rana Jan 12 '15 at 07:10
-
Add Connectoinstrnig in web.config file
-
Now it is showing-"The ADO.NET provider with invariant name 'System.Data.EntityClient' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details." – Deepak Jan 12 '15 at 07:13
1 Answers
0
Add the connection string to web.config,
<!--web.config of the project that is utilizing Entity Framework-->
<connectionStrings>
<add name="YourConnectionName"
providerName="System.Data.SqlClient"
connectionString="Server=YourServerNameOrIP; Database=YourDatabaseName;
Integrated Security=SSPI" />
</connectionStrings>
Now, Specify your connection string to DbContext
// In the class inheriting from DbContext
namespace Context
{
public class Dbc : DbContext
{
public Dbc() : base("YourConnectionName") { }
public DbSet<Message> Messages { get; set; }
}
}

Afzal Ahmad
- 586
- 5
- 20
-
Now I am getting this error-"Unable to find the requested .Net Framework Data Provider. It may not be installed." – Deepak Jan 12 '15 at 07:27
-
http://stackoverflow.com/questions/21157069/unable-to-find-the-requested-net-framework-data-provider-it-may-not-be-install – Afzal Ahmad Jan 12 '15 at 07:47
-
@Deepak You need to install Microsoft SQL Server Compact 4.0 which will take the error message away – Izzy Jan 12 '15 at 09:18
-
Okay, I got it.All I need to do was to specify the correct folder path in connection string(inside web.config)as it was not there.Thank u all for your help...:) – Deepak Jan 13 '15 at 10:07
-