记 asp.net core

现在的版本是   1.1.0 

机器是 win10

官方文档是 https://docs.microsoft.com/en-us/aspnet/core/ 

使用vs2015.3 新建一个asp.net core 项目后,使用 dotnet restore 还原程序包。 程序包 是使用project.json 记录的,程序包 也不存在项目文件下了。  

项目生成

使用命名生成 dotnet  build 或VS 生成,会抛出一个运行时错误,

Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x64, win81-x64, win7-x64'

需要在  project.json 中 添加 一个 配置  

  "runtimes": {
    "win10-x64": {}
  },

ef core 

文档地址 :  https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/ 

目前 EF core 不支持多对多 模式,不过可以用折中方法 多 -- 一 -- 多 

在 命令行下(CMD) migragions 命令变成了  dotnet ef  开头。命令需要定位到 migrations 文件夹所在的项目文件夹。  

新建变更  dotnet ef migrations add [migration-name]     -c [context-name]     (-c 可以省略,如果只有一个context)

应用变更到数据库  dotnet ef database update -c [context-name]    

CLI 所有命令:https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet 

ef core 版本 从 1.0.0 升级到1.1.0 后,执行命令出错  No executable found matching command "dotnet-ef" 

解决方法: tools 项 中添加 "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"  

 

 

 

Snippet

已禁用评论。