0

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?

Deepak
  • 1

1 Answers1

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
  • Do a thumb up if this helps you, So others can also use this, – Afzal Ahmad Jan 13 '15 at 10:08