You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dnx add migration, IHostingEnvironment.WebRootPath is null #4494
I have an ASP.NET 5 WebApplication, and an EF 7 db context (RC 1 Final) in a seperate project.
When I CD to my web project directory, and run dnx ef migration add InitialMigration -p SomeEfDataProject
I am getting an exception to do with the fact that during initialisation, my application makes use of IHostingEnvironment.WebRootPath which is Null within the context of executing the dnx migration command line.
Shouldn't this be set to something?
My application startup logic uses IHostingEnvironment.WebRootPath to figure out a path to a local drop folder, where plugin (mef) components can be dropped and loaded during app startup.
Setting WebRootPath to an empty value or a fake value, might help. I don't think when people are developing an asp.net 5 web application that they would expect the 'WebRootPath' to potentially be Null. In the normal case this is always set to something. In the EF migration case, because it's not it will catch people out with null ref exceptions.
We could provide a better value for WebRootPath, but it would still be wrong for some projects. We could also go back to taking a dependency on Hosting, but there sure was a lot of pushback...
Not sure I understand. The webroot for an asp.net 5 (dnx) project is specified in the project.json file, so is this not a simple case that EF (migrations), when running the project, can check for this value in the project.json file and set the WebRootPath on IHostingEnvironment appropriately. That logic should then result in this value being set correctly for all dnx based projects unless I am missing something!
Activity
dazinator commentedon Feb 4, 2016
I have worked around this by chucking this in my startup logic, seems to solve it.
rowanmiller commentedon Feb 5, 2016
cc @bricelam... seems like there probably isn't much we can do here?
dazinator commentedon Feb 5, 2016
Setting
WebRootPathto an empty value or a fake value, might help. I don't think when people are developing an asp.net 5 web application that they would expect the 'WebRootPath' to potentially be Null. In the normal case this is always set to something. In the EF migration case, because it's not it will catch people out with null ref exceptions.bricelam commentedon Feb 5, 2016
We could provide a better value for
WebRootPath, but it would still be wrong for some projects. We could also go back to taking a dependency on Hosting, but there sure was a lot of pushback...dazinator commentedon Feb 6, 2016
Not sure I understand. The webroot for an asp.net 5 (dnx) project is specified in the project.json file, so is this not a simple case that EF (migrations), when running the project, can check for this value in the project.json file and set the WebRootPath on IHostingEnvironment appropriately. That logic should then result in this value being set correctly for all dnx based projects unless I am missing something!
rowanmiller commentedon Feb 12, 2016
Closing in favor of a more general issue to sort out how we interact with Startup #4546