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