Asp.net core 三层考试管理系统

asp.net core 三层考试管理系统[持续更新]

技术:

​ asp.net core 3.1

​ mysql 5.7

​ EF Core Code First

1、 功能图

2、数据库逻辑

3、Code First 映射数据库

3.1 连接字符串

写在UI层 appsettings.json 里面

"ConnectionStrings": {
  "ExamOnlineCon": "server=localhost;user id=root;password=root;database=ExamOnlineDb;charset=utf8;sslMode=None"
},

3.2 上下文Context

写在 DAL层 MySqlContext.cs里面

 public class MySqlContext:DbContext
  {
      public MySqlContext(DbContextOptions<MySqlContext> options) : base(options)
      {
          //在此可对数据库连接字符串做加解密操作
      }

      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
      }

      DbSet<TbAnswerCard> tbAnswerCards { get; set; }
      DbSet<TbClass> tbClasses { get; set; }
      DbSet<TbImages> tbImages { get; set; }
      DbSet<TbObjectiveTopic> tbObjectiveTopics { get; set; }
      DbSet<TbQuestionTypes> tbQuestionTypes { get; set; }
      DbSet<TbResult> tbResults { get; set; }
      DbSet<TbScore> tbScores { get; set; }
      DbSet<TbSpeciality> tbSpecialities { get; set; }
      DbSet<TbStudent> tbStudents { get; set; }
      DbSet<TbSubject> tbSubjects { get; set; }
      DbSet<TbTeacher> tbTeachers { get; set; }
      DbSet<TbTestPaper> tbTestPapers { get; set; }
      DbSet<TbUser> tbUsers { get; set; }
  }

在DAL console 执行以下命令

Add-Migration mysql1

Update-Database

posted @ 2020-02-19 20:58  乾子  阅读(595)  评论(1编辑  收藏  举报