首页 > 代码库 > MVC学习笔记

MVC学习笔记

  1. CodeFirst生成数据库步骤
    webconfig配置
    <connectionStrings>
    <add name="AuthorDesignContext" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=AuthorDesign;Integrated Security=False;User Id=sa;Password=123456;MultipleActiveResultSets=True" />
    </connectionStrings>
    <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>

    包管理器

    程序包管理器控制台输入Enable-migrations
    然后输入add-migration AddDatabase(AddDatabase是数据库名)
    最后输入Update-Database

     

MVC学习笔记