EF7 RC2 代码首先创建数据库
EF7 RC2 Code First Create Database
我在我的 ASP.NET 核心 RC2 应用程序中使用 EF7 RC2,我正在尝试从代码生成我的数据库(我先使用代码)。我创建了我的上下文,并设置了我的连接字符串,但是当我在 VS2015 的 NuGet 控制台中输入 "Add-Migration" 时,我收到一条错误消息
The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program.
我做了一些挖掘,我认为该命令是 RC1 的东西。是否有 RC2 等效项?是否有任何适用于 EF7 RC2 的教程?我能找到的都是 RC1 或早期的。
在使用从 RC2 安装的新 dotnet
工具的常规命令提示符下,您应该能够在项目目录中执行以下操作:
dotnet ef migrations add [name]
快速说明一下,您可能想要浏览新命令以查看每个项目的全部内容。例如 dotnet
与 dotnet ef
(https://blogs.msdn.microsoft.com/dotnet/2016/05/16/announcing-net-core-rc2/)
您可能需要确保安装了 Powershell 5 才能使其在程序包管理器控制台中运行:
您还需要将其添加到您的 project.json 文件中,并将 "Microsoft.EntityFrameworkCore.Tools" : "1.0.0-preview1-final"
添加到您的依赖项中。
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
}
这是针对实体核心的,但您可以尝试。这些是您需要的两个命令:
dotnet ef migrations add somename
dotnet ef database update
对于 Entity Core...转到 visual studio 中的包管理器,然后只需键入:update-database
这应该在指定的持久存储中创建表
我在我的 ASP.NET 核心 RC2 应用程序中使用 EF7 RC2,我正在尝试从代码生成我的数据库(我先使用代码)。我创建了我的上下文,并设置了我的连接字符串,但是当我在 VS2015 的 NuGet 控制台中输入 "Add-Migration" 时,我收到一条错误消息
The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program.
我做了一些挖掘,我认为该命令是 RC1 的东西。是否有 RC2 等效项?是否有任何适用于 EF7 RC2 的教程?我能找到的都是 RC1 或早期的。
在使用从 RC2 安装的新 dotnet
工具的常规命令提示符下,您应该能够在项目目录中执行以下操作:
dotnet ef migrations add [name]
快速说明一下,您可能想要浏览新命令以查看每个项目的全部内容。例如 dotnet
与 dotnet ef
(https://blogs.msdn.microsoft.com/dotnet/2016/05/16/announcing-net-core-rc2/)
您可能需要确保安装了 Powershell 5 才能使其在程序包管理器控制台中运行:
您还需要将其添加到您的 project.json 文件中,并将 "Microsoft.EntityFrameworkCore.Tools" : "1.0.0-preview1-final"
添加到您的依赖项中。
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
}
这是针对实体核心的,但您可以尝试。这些是您需要的两个命令:
dotnet ef migrations add somename
dotnet ef database update
对于 Entity Core...转到 visual studio 中的包管理器,然后只需键入:update-database
这应该在指定的持久存储中创建表