There are two EF7
db-contexts in a MVC6 (beta-7)
project. First of them (let's call it StartupContext
) is in a startup project ( MyProject.Startup
). Second (let's call it DataContext
) is in a separate assembly ( MyProject.Data
).
There is a command in the project.json
files of the MyProject.Startup
and the MyProject.Data
:
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta7",
"EntityFramework.Commands": "7.0.0-beta7",
...
}
"commands": {
"ef": "EntityFramework.Commands"
...
}
I can use it for a database updating like this:
for an updating of the StartupContext
I run the ef
command from a startup folder:
dnx ef database update
for an updating of the DataContext
I run the ef
command from a folder of the MyProject.Data
project:
dnx ef database update -c DataContext -s MyProject.Startup
It works perfectly but only from sources (from not published project). I get exception like this for an updating of the DataContext
from a published project:
System.IO.FileNotFoundException: Could not load file or assembly "MyProject.Data" or one of its dependencies.
I tried various approaches:
dnx ef database update -c DataContext -s MyProject.Startup
dnx ef database update -c DataContext -s C:\Published\approot\packages\MyProject.Startup
dnx ef database update -c DataContext -s C:\Published\approot\packages\MyProject.Startup\1.0.0\root\
dnx ef database update -c DataContext -s C:\Published\approot\packages\MyProject.Startup\1.0.0\lib\MyProject.Startup.dll
dnx ef database update -c DataContext -s %~dp0approot\packages\MyProject.Startup
dnx ef database update -c DataContext -s %~dp0approot\packages\MyProject.Startup\1.0.0\root\
I also tried to copy the MyProject.Startup.dll
to a folder with the MyProject.Data
but unsuccessfully.
Has anybody else had a similar problem?
How can I update a database and create a migration from a published project?
This is a bug in EF7-beta7 and should be fixed in the upcoming RC1 release of EF.
If you need (as in very much so) this feature before the, you could use the nightly builds of EF. (Caution: nightly builds have a lot of instability.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.