1、public class   dbContext:Dbcontext

{

private readonly static string CONNECTION_STRING="name=dkcms2";

public dbContext():base(CONNECTION_STRING)

{

}

//public DbSet<Article> articles{get;set;}

}

2、<add name ="自己写连接名称" connectionString=""/>

Get-Package
    Install-Package
    Uninstall-Package
   
Update-Package
    Add-BindingRedirect
    Get-Project
   
Open-PackagePage
    Register-TabExpansion

3、install-package entityframework

enable-migrations  开启迁移

add-migration  aaa  查看修改

update-database  更改到数据库

4、建立Model 关联到dbContext

注意空格

install-package entityframework -project domain

开启迁移

enable-migrations -ContextTypeName "EFDbContext" -ProjectName "Domain" -StartUpProjectName "WebUI" -ConnectionStringName "ApplicationServices"

查看修改

Add-Migration -Name "a"  -ProjectName "domain" -StartUpProjectName "WebUI"
-ConnectionStringName "ApplicationServices"

更新到数据库

update-database -script -projectName "Domain" -StartUpProjectName "WebUI"
-ConnectionStringName "ApplicationServices"

不能建立表 因为这个参数 -script 去掉

update-database -projectName "Domain" -StartUpProjectName "WebUI"
-ConnectionStringName "ApplicationServices"

05-10 23:20