In the Entity Framework you need to tell the context what the database connection is, this is done by moving to the base class : base("DataContext")
your connection name as shown below.
public class ProjetoModeloContext : DbContext
{
public ProjetoModeloContext()
: base("DataContext")
{
}
public DbSet<Categories> Categories { get; set; }
}
Configuration of connectionStrings
on the web config, just below the </appSettings>
</appSettings>
<connectionStrings>
<add name="DataContext" connectionString="Server=SEU_SERVIDOR; database=NORTHWND;User ID=SEU_USUARIO;Password=SUA_SENHA" providerName="System.Data.SqlClient" />
</connectionStrings>
What do you mean "it’s weird"? What’s happening? Click [Edit] and give more details...
– Jéf Bueno
This is not a Connection string. This is the EF configuration. A Connection string is among
<connectionStrings></connectionStrings>
.– Leonel Sanches da Silva
So, man, how do I connect to the database with the Entityframework configuration on ASP.NET?
– Wermerson Washington