Reputation: 430
I am using .net core and entity framework core 1.1.0. while trying the following command in Package Manager Console
Scaffold-DbContext "Server=MyServer\\MyInstance;Database=MyDB;user=MyUsername;password=MyDbPassword;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -t Table1,Table2
I am getting this error
Could not find assembly 'D:\Work\Projects\src\MyProject\src\MyProject.Api.\bin\Debug\net461\win7-x64\MyProject.Data.exe'.
MyProject.Data is a net core library. MyProject.Api is a .net full framework core api, which references the MyProject.Data.
project.json file of MyProject.Data
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
},
"frameworks": {
"net461": {}
}
}
Any advice for me?
Upvotes: 7
Views: 9469
Reputation: 66
I have been trying to scaffold a FireBird database. The first issue is that the FireBird file was made in 32bit. Because of that, my project had to target x86. I had then messages "could not load assembly ensure it is referenced by the startup project". The solution to remove those messages was :
fbembed.dll
icudt30.dll
icuuc30.dll
msvcr80.dll
side by side with the csprojC:\Program Files (x86)\dotnet\
in the system environment variables above C:\Program Files\dotnet\
& 'C:\Program Files (x86)\dotnet\dotnet.exe' ef dbcontext scaffold "ServerType=1;Database=PATH_TO_THE_FDB;user id=THE_USER;password=THE_PASSWORD" FirebirdSql.EntityFrameworkCore.Firebird --configuration=debug --verbose
, ServerType=1 is for using Firebird in embedded modeWhat helped me to go down this path was this github issue, Procmon then helped me to see that the dotnet process was in x64.
Upvotes: 0
Reputation: 9606
Not sure if this is a bug, but scaffold-dbcontext
command looks for the assembly in Startup Project.
There are two workarounds for this issue
scaffold-DBContext
command to set a particular project as startup project while running the command.
This is what you need to add at the end of command...-StartupProject MyProject.Data
Upvotes: 14
Reputation: 369
It seems that this issue also occurs if the target platform is x86.
Switching to AnyCPU solves the problem.
Upvotes: 7