【发布时间】:2012-01-22 16:38:39
【问题描述】:
默认情况下,add-migration 命令会尝试在其中创建迁移 .cs 文件
- 项目根目录
- 迁移
我想将我的迁移连同其他与 EF 相关的代码一起存储在我项目的 \Data 文件夹中:
- 项目根目录
- 数据
- 迁移
- 数据
有了这个结构,当我执行时
PM> add-migration Migration1
在 NuGet 控制台中,我收到以下错误:
System.IO.DirectoryNotFoundException:找不到路径“C:\MyProjectRoot\Migrations\201112171635110_Migration1.cs”的一部分。 在 System.IO.__Error.WinIOError(Int32 错误代码,字符串可能全路径) 在 System.IO.FileStream.Init(字符串路径、FileMode 模式、FileAccess 访问、Int32 权限、Boolean useRights、FileShare 共享、Int32 bufferSize、FileOptions 选项、SECURITY_ATTRIBUTES secAttrs、String msgPath、Boolean bFromProxy、Boolean useLongPath) 在 System.IO.FileStream..ctor(字符串路径、FileMode 模式、FileAccess 访问、FileShare 共享、Int32 bufferSize、FileOptions 选项) 在 System.IO.StreamWriter.CreateFile(字符串路径,布尔附加) 在 System.IO.StreamWriter..ctor(字符串路径,布尔附加,编码编码,Int32 缓冲区大小) 在 System.IO.StreamWriter..ctor(字符串路径,布尔附加,编码编码) 在 System.IO.File.InternalWriteAllText(字符串路径,字符串内容,编码编码) 在 System.IO.File.WriteAllText(字符串路径,字符串内容)是否可以在执行 add-migration 命令时指定要在磁盘上创建迁移文件的位置?
【问题讨论】:
-
请将 Roger 的解决方案标记为答案。它对我有用。谢谢。
标签: entity-framework-4 entity-framework-migrations