You should remember that you must download entity frame work from nuget pakasge manager
public class Student
{
[Key]
public int StudentId { get; set; }
public string Name { get; set; }
public int standard { get; set; }
public string CollegeName { get; set; }
public string Address { get; set; }
}
public class StudentContext : DbContext
{
public DbSet<Student> Students { get; set; }
}
web config
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="StudentContext" connectionString="Data Source=(LocalDB)\MSSQLLocalDB; Initial catalog=CodeFirstEFDB; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
No comments:
Post a Comment