EFCore Commands with (or without) CLI
I can't seem to create migrations or update the database using EFCore and CLI.
My target framework is dnx451. From #4555 I've see that I have to use restore and build first. But I then get the error Failed to initialize CoreCLR.
From #4647 I see
CLI only targets DNXCore
so I tried adding dnxcore50 but I get the same error. (By the way - is this really true? What if I only need 451, then is my only option to include a redundant framework?)
I see from #3925 that this should be working. What am I missing? I'm only using CLI because I can't use dnx ef any more (correct?), if there's another way then please tell me what that is, as at the moment I've made changes I can't apply to the database so development is stuck.
.
Wait for RC2 :cry:
@ErikEJ I'm using the RC2 builds. My understanding is that it should be implemented in those builds already.
I've finally got past the Failed to initialize error, I have no idea how, but now when I run dotnet ef database update I get Could not load file or assembly 'System.Data.SqlClient'
Hi, Sean! Command dotnet ef with following project.json structure is executed successfully:
"frameworks": {
"dnx451": { },
"dnxcore50": {
"imports": "portable-net452+win81",
"dependencies": {
"dotnet-ef": "1.0.0-*"
}
}
},
"tools": {
"dotnet-ef": "1.0.0-*"
},
But with command dotnet ef database update or dotnet ef dbcontext list I get another error:
System.IO.FileLoadException: Could not load file or assembly 'openiddict-test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
And the project start with net::ERR_CONNECTION_REFUSED error. Any ideas?
Things are still going to be pretty volatile in our working code base for a little while yet. Things tend to work one day and then break the next as the various pieces that we depend on are churning. If RC1 works for you, then I would use that. If not, when you find a "nightly" build that works for you, I would pin to that build and not auto upgrade to the latest.
This is unfortunately part of using nightly builds... you opting into the interim states that things go thru between stable releases - welcome to the pain :smile:.
Closing this one out as we know the commands are not completely stable yet and we are using #3925 to track having stable CLI commands for the RC2 release.
Thanks @rowanmiller - I appreciate that it's in a state of flux at the moment. Unfortunately I'm tied to RC2 and can't go back to RC1 due to a dependency on OpenIddict. I had assumed that since #3925 was marked Closed that the EF Commands should now be working with CLI and I was doing something wrong or there was a bug I had stumbled upon.
@sergekolchin you shouldn't have dotnet-ef in your dependencies.
@rowanmiller Can I just confirm with you that this isn't a bug. I've created the simplest repo at: https://github.com/capesean/eftest. It's got a DbContext with a single entity. I can run dotnet ef migrations add test and it works, creating the migration. But when I run dotnet ef database update it bombs with the missing SqlClient error. I just want to be 100% sure you're aware of this as the ability to apply migrations is a bit of a show-stopper, and I can't find anything that says this isn't currently possible.
@capesean I'll continue testing the commands. When I merged, everything was working. The next morning, CLI seemed to have broken us again.
@bricelam is it possible I've got the wrong dotnet ef tools/package? I noticed from MyGet that it's on 20019 and my artifacts folder had 16937. Similarly EntityFrameworkCore.Commands is at 20019 and I had 16937. I changed my Nuget.Config file to include the feeds as shown below and now I'm running with 20019 packages, but the SqlCient issue remains. So I'm pretty sure I'm using the latest builds but I include it here in case I'm missing something obvious.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetCI" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="dotnet-cli" value="https://www.myget.org/F/dotnet-cli/api/v3/index.json" />
</packageSources>
</configuration>
It repros on the latest bits. I'm debugging through it now...