asp.net core 使用EntityFrameWork遇到的问题

1) “类库”类型的工程目前不支持,改用app类型的工程
看官方文档的说明:
.NET Core CLI does not support running commands on class libraries as of Preview 1. Despite being able to install EF tools, executing commands may throw this error message.

This preview of Entity Framework tools does not support targeting class library projects in ASP.NET Core
and .NET Core applications.

2)添加Microsoft.EntityFrameworkCore.SqlServer包报错,project.json 的frameworks imports中增加 “portable-net452+win81”


"frameworks": {
      "netcoreapp1.0": {
        "imports": [
          "dnxcore50",
          "portable-net452+win81"
        ]
      }
    }

添加一段tools import:

"tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net452+win81+dnxcore50",
        "portable-net452+win81"
      ]
    }
  }

3) 连接远程数据库生成Model时报错,改为在本地建立数据库(只要数据库结构,不需要数据)再执行命令生成Model,最后成功的语句是:

Scaffold-DbContext "'Server=JIMLAI;Database=HtempCloudDev;Trusted_Connection=True;'" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DBModel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值