public class StudentTable
{
public int Id{ get; set;}
public string Name { get; set;}
public string Aex { get; set;}
public int Age { get; set;}
}[/quote]
你这里的Id Name Aex Age 没有什么要求吗?那怎么能和数据库联系起来并进行数据存取?[/quote]
你先建个数据库,然后手动建表,表的每个属性对应的名称分别为Id Name Sex Age,然后你在MOdel文件夹里添加一个StudentTableContext类,并让它继承DbContext类,(注意要导入命名空间),如下:
public class StudentTableContext : DbContext
{
public StudentTableContext():base("StudentTable"){}//StudentTable是数据库的名称
public DbSet<StudentTableEntry>Entries{ get; set;}//StudentTableEntry是你建的表的名称
}
public class StudentTable
{
public int Id{ get; set;}
public string Name { get; set;}
public string Aex { get; set;}
public int Age { get; set;}
}[/quote]
你这里的Id Name Aex Age 没有什么要求吗?那怎么能和数据库联系起来并进行数据存取?