我EntityFramework -Version 6.1.2使用Visual Studio 2013最新更新启动了一个新的MVC项目.我进行了几次迁移并更新了数据库.在此之后,我在另一台计算机上检出了该项目,并使用Visual Studio 2015 CTP 6打开.
如果我进入包管理器控制台并尝试运行任何迁移命令,则无法识别它们:
add-migrations:术语"add-migrations"不被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.
如何在Visual Studio 2015中使用Entity Framework 6管理我的迁移?
c# entity-framework ef-migrations entity-framework-6 visual-studio-2015
我正在使用asp.net 5和MVC 6建立一个新项目,但由于EF 7缺少功能,我想使用Entity Framework 6.
我设置了EF 6.1.3,这是有效的.
Identity 3.0依赖于EF 7,因此我删除了它并在Identity 2.2中引用但我不确定从何处开始.
我正在使用Asp.net 5.0 mvc6,我想使用entityframework 6,因为7还没有完全编码,我已经能够让它做除了迁移之外的一切.
当我输入enable-migration,add-migration或update-datatabase时,我得到了
enable-migration : The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ enable-migration
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (enable-migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
我很确定这些命令不在PowerShell中.但我确实发现%userdir%.dnx\packages\EntityFramework\_6.1.3\tools中有工具.稍微研究一下migrate.exe,我发现它们告诉我它只适用于proj文件,因此无法使用新设置.
我也尝试在dbcontext的构造函数中使用此代码进入编程路径,我有:
var configuration = new MigrationConfiguration();
var migrator = new DbMigrator(configuration);
migrator.Configuration.TargetDatabase = new DbConnectionInfo(nameOrConnectionString, …Run Code Online (Sandbox Code Playgroud)