在EF迁移配置类的Seed方法中获取App_Data文件夹的路径

NVM*_*NVM 6 ef-code-first asp.net-mvc-4 ef-migrations entity-framework-5

如何在代码首次迁移的配置类的Seed方法中获取App_Data文件夹的路径.

我想从我放在App_Data文件夹中的文件中读取,并且在update-database命令之后运行Seed方法.HttpContext.Current.Server.MapPath显然不起作用,因为此时没有HttpContext.

Rus*_*ine 2

这是一个快速入门的方法:

var myPath = AppDomain.CurrentDomain.BaseDirectory;
//to quickly show the path, either attach another debugger or just throw an exception
throw new Exception(myPath);
Run Code Online (Sandbox Code Playgroud)