In my entity framework Seed method I have the following line to get a file from a different project:
var filePath = new DirectoryInfo(HostingEnvironment.ApplicationPhysicalPath).Parent.FullName + "\\Com.ProjectX\\companies.xls";
This works when a HttpContext is available, like when using this action method to trigger it:
public ActionResult About()
{
var configuration = new Com.EntityModel.Configuration();
var migrator = new System.Data.Entity.Migrations.DbMigrator(configuration);
migrator.Update();
return View();
}
However, it doesn't work when I execute Update-Database
from the package manager console (the file isn't found and it's hard to debug because I also can't breakpoint when doing that.
I'd like to be able to use Update-Database command and have it work without an HttpContext. How can I get the path?