In the Entity Framework you need to tell the context what the connection is for the database, this is done by passing the base class
: base("DataContext")
the name of your connection as shown below.
public class ProjetoModeloContext : DbContext
{
public ProjetoModeloContext()
: base("DataContext")
{
}
public DbSet<Categories> Categories { get; set; }
}
Configuring connectionStrings
in web config, just below </appSettings>
</appSettings>
<connectionStrings>
<add name="DataContext" connectionString="Server=SEU_SERVIDOR; database=NORTHWND;User ID=SEU_USUARIO;Password=SUA_SENHA" providerName="System.Data.SqlClient" />
</connectionStrings>