日期:2014-05-17 浏览次数:20427 次
Database.SetInitializer<SchoolContext>(new SchoolInitializer());
public class SchoolContext
: DbContext
{
public DbSet<Student> Students { get; set; }
public DbSet<Enrollment> Enrollments { get; set; }
public DbSet<Course> Courses { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
<add name="SchoolContext"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=School;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=admin888;Connect Timeout=120"
providerName="System.Data.SqlClient" />
<add name="SchoolContext"
connectionString="server=.\SQLEXPRESS;database=School;integrated security=true;"
providerName="System.Data.SqlClient"/>