我正在尝试使用代码优先方法为在线考试系统创建一个数据库。我已经创建了我的数据模型,我的上下文类,setInitializer在文件中添加了我的方法Global.asax,添加了我的连接字符串。
但是仍然没有创建数据库。真的需要一些帮助。
我的连接字符串:
<connectionStrings>
<add name="ExamDbContext"
connectionString="server=LAPTOP-JJKI9JN7; Initial Catalog=OnlineExamSystem; Integrated Security=true;"
providerName="System.Data.SqlClient">
</add>
</connectionStrings>
LAPTOP-JJKI9JN7是我的 SSMS 服务器名称
学生表:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace Online_Exam_System.Models
{
public class TBL_STUDENT
{
public int S_ID { get; set; }
[Display(Name = "Student")]
[Required(ErrorMessage = "The field is required")]
public string S_NAME { get; set; }
[Display(Name = "Password")]
[Required(ErrorMessage = "The field is required")]
public string S_PASSWORD { get; set; }
[Display(Name = "Marks")]
[Required(ErrorMessage = "The field is required")]
public Nullable<int> S_MARKS { get; set; }
}
}
动漫人物
相关分类