zoukankan      html  css  js  c++  java
  • Code First Migrations to update the table

    1.模型类User

        public class User
        {
            [Key]
            public string Username { get; set; }
            public string DisplayName { get; set; } 
        }

    2.修改DbContext

        public class BaseDbContext:DbContext
        {
            private static readonly string Connection = ConfigurationManager.AppSettings["DbConnection"].ToString();
            public BaseDbContext()
                : base(Connection)
            {
                this.Database.CreateIfNotExists();
            }
            public DbSet<Blog> Blogs { get; set; }
            public DbSet<Post> Posts { get; set; }
            //新增
            public DbSet<User> Users { get; set; } 
        }

    3.在程序包管理器控制执行指令 Enable-Migrations

    4.Add-Migration AddUser

    5.Update-Database

  • 相关阅读:
    pytorch基础(4)-----搭建模型网络的两种方法
    Java
    Tools
    Maven
    Java
    DevOps
    Linux
    Java
    Java
    Nutch 使用总结
  • 原文地址:https://www.cnblogs.com/liandy0906/p/8464220.html
Copyright © 2011-2022 走看看