zoukankan      html  css  js  c++  java
  • Asp.net WebForm使用codeFirst建立和修改数据库小结

    在asp.net4.5框架下使用codeFirst添加和修改数据库文件小结。

    建立:

    1、建立模型类

    2、In Package Manager Console, run the command:
    enable-migrations -ContextTypeName ContosoUniversityModelBinding.Models.SchoolContext

    3、系统自动产生configuration.cs文件,其中的seed方法用来初始化数据库

    4、Run the command update-database

    5、The database file has been added

    修改:

    1、修改模型类的字段

    2、 In the Package Management window, add a migration by running the command add-migration AddEnrollmentDate. Notice that the migration code adds the new Datetime column to the Student table.

    3、Therefore, open Configuration.cs in the Migrations folder and remove or comment out the code in the Seed method. Save and close the file.

    4、Now, run the command update-database

  • 相关阅读:
    Linux监控内核SNMP计数器
    wireshark使用手册
    【LinuxShell】echo用法详解
    【Coredump】调试之旅
    汇编指令
    从零开始学Java (五)条件选择
    从零开始学Java (四)输入输出
    Dart基础
    树相关
    递归简介
  • 原文地址:https://www.cnblogs.com/xzitluyang/p/6130778.html
Copyright © 2011-2022 走看看