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