mrahhal / Migrator.EF6

.NET Core CLI tool to enable EF6 migrations in an Asp.Net Core app.
MIT License
82 stars 15 forks source link

Add support for .NET Core 3.0 #67

Closed marchy closed 4 years ago

marchy commented 5 years ago

Hi @mrahhal, I'm starting this out as a way to assess the viability of running Migrator.EF6 on .NET Core 3.0.

I tried upgrading the project to .NET Core 3.0 (work-in-progress commit here) but ran into the following issues:

Issues **ISSUE 1:** ``` Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at Microsoft.DotNet.Cli.Utils.Command.Execute() at Migrator.EF6.Tools.Program.Dispatch(String[] args) at Migrator.EF6.Tools.Program.Main(String[] args) ``` Looked into this and it turned out to be caused by looking for the 'dotnet-ef6.exe', where for some reason in the .NET Core 3.0 version it generates it as a DLL ('dotnet-ef6.dll'). I'm not sure if there's a right way to generate an executable for this, but just hard-coding it to .dll for NETCOREAPP got things to the next issue: **ISSUE 2:** ``` Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.Assembly.GetTypes() at Migrator.EF6.Tools.Executor..ctor(Boolean verbose, String connectionString, String providerName, String context) at Migrator.EF6.Tools.CommonConfiguration.CreateExecutor() at Migrator.EF6.Tools.MigrationsCommand.<>c__DisplayClass1_4.b__8() at Migrator.EF6.Tools.Extensions.CommandLineApplicationExtensions.<>c__DisplayClass0_0.b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Migrator.EF6.Tools.Worker.Execute(String[] args) at Migrator.EF6.Tools.Program.Main(String[] args) ```

Let me know if you've tried and have gotten any further on this.

With the imminent release of .NET Core 3.0 perhaps we can give the EF team some feedback on how feasible migrating the current Migrator.EF6 is and what issues it's running into which they may be able to jump in and assess further.

mrahhal commented 5 years ago

Hi @marchy,

I haven't yet, but I wanted to start on this because the standing about an official tool for 3.0 is still vague, but had no time so far. Thank you for starting this.

Gonna look into it today.

EDIT: I'm a bit ahead and I think I can get it to work but there are a couple of problems I'll share in a bit.

mrahhal commented 5 years ago

So good news, I got a prototype fully working.

BTW, one foundational part about this transition to .NET Core 3.0 is that we don't need to do any dispatching anymore because we're always in the context of netcore. I'm glad this overhead is gone but it'll require a lot of refactoring.

Also, I see that dotnet-ef has been changed to work as a global tool, primarily. And I wasn't even able to make dotnet-ef6 work in-project after I changed things so I converted it to global too.

Anyway, couple of problems/worries.

1.

Resources are all messed up in this release. I'm not sure exactly who's responsible but I had to manually edit (in addition to adding DependentUpon in the csproj) the designer cs files (*.Designer.cs). For example, one old resource id was: BasicConsoleApp.Migrations.201802152032477_add_Blog.Some2 but I had to change it into: BasicConsoleApp.Migrations.add_BlogSome2. So it seems it's embedding these files in the name of the class now. Totally different behavior.

Not sure what to do here, as both those changes (DependentUpon and Designer files) require changes in the consumer's project, in which I have no control. If I could go back I would have completely dropped this resx thing and just used plain files..

2.

I had to write a simple impl of ResXResourceWriter because it's part of Windows Forms and we can't use it anymore. Couldn't find a netcore impl so far.

3.

I know I said we don't need dispatching anymore, but I'm a bit worried. I haven't interacted with cli tools for quite some time so I don't know exactly, but if the consumer project is using a different version of .net core than what I've built against, would that still work without dispatching? Not sure.


(I removed the other samples and kept only the basic console app until I can iron this out.)

I pushed to netcore-3.0 branch. Check the PR at https://github.com/mrahhal/Migrator.EF6/pull/68.

marchy commented 5 years ago

Hi Mohammad, trying to test this out, got the global tool installed but this is what I get running on our project:

C:\....\Domain>dotnet ef6 migrations list -c EF6DatabaseContext
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
Could not load file or assembly 'Twilio, Version=5.6.5.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Migrator.EF6.Tools.Executor..ctor(Boolean verbose, String connectionString, String providerName, String context) in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\Executor.cs:line 41
   at Migrator.EF6.Tools.CommonConfiguration.CreateExecutor() in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\CommonConfiguration.cs:line 71
   at Migrator.EF6.Tools.MigrationsCommand.<>c__DisplayClass1_4.<ConfigureInternal>b__8() in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\MigrationsCommand.cs:line 136
   at Migrator.EF6.Tools.Extensions.CommandLineApplicationExtensions.<>c__DisplayClass0_0.<OnExecute>b__0() in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\Extensions\CommandLineApplicati
onExtensions.cs:line 12
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Migrator.EF6.Tools.Worker.Execute(String[] args) in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\Worker.cs:line 5
   at Migrator.EF6.Tools.Program.Main(String[] args) in C:\Users\marchy\Documents\Projects\_LIBRARIES\dotNET\Migrator.EF6\src\Migrator.EF6.Tools\Program.cs:line 19
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Relational, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

System.IO.FileNotFoundException: Could not load file or assembly 'Twilio, Version=5.6.5.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Twilio, Version=5.6.5.0, Culture=neutral, PublicKeyToken=null'

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Any thoughts?

Not sure if this has to do with the 'Remove everything EF Core related' step or the change in dispatching, but the project has had EF Core and EF6 side by side with all the previous versions of EF6.Migrator, simply pointing to the right context with the -c option.

Could we get a branch up where it uses the dispatching approach still?

mrahhal commented 5 years ago

Just to know if this is related to your machine or the project, could you run it on the BasicConsoleApp sample in this repo and let me know if it works or not?

marchy commented 5 years ago

@mrahhal it seems to run fine on the BasicConsoleApp.

I'm unfamiliar with the differences between the dispatching and not, but it feels like it could be the culprit.

Any way you can get a branch up where it uses the previous dispatching approach so I can see if it makes a difference?

I tried to get it working (branch: https://github.com/marchy/Migrator.EF6/commits/netcore-3.0-dispatch) but the dotnet-ef6.dll isn't being generated into the build output dir anymore (presumably due to the removal of the lines below), and I wasn't sure how to get it up and running with the old approach.

<PackageReference Include="Migrator.EF6.Tools" Version="$(MigratorVersion)" PrivateAssets="All" />
<DotNetCliToolReference Include="Migrator.EF6.Tools" Version="$(MigratorVersion)" />
mrahhal commented 5 years ago

Sorry for being late.

Checked your changes a bit. Keeping NET46 preprocessors won't do, they're not needed, but probably not the reason there's a problem. I'll see if I can get a branch with only the necessary dispatching code so that you can try that.

mrahhal commented 5 years ago

Ah. While looking at the dispatching code, the idea that dispatching shouldn't be needed is becoming more tangible. I'm not sure I can get dispatching to work at all after the required changes in .net 3.0.

but the dotnet-ef6.dll isn't being generated into the build output dir anymore (presumably due to the removal of the lines below), and I wasn't sure how to get it up and running with the old approach.

That's because the tool now is a global cli tool, so yeah that's normal.

Looking a bit into the ef core tool, I just can't find any mention of dispatching either.

So, I might have to try to debug through the first problem you mentioned of not being able to load files, in a new project or something.

marchy commented 5 years ago

Hmm okay thanks for looking further into that (non)option =)

Let me see if I can set up a barebones project where I can reproduce the initial problem. Priorities are a bit tight right now though so we might have to revisit this again in October. Guess it's a no-go on the 3.0 update for the time being 😞

mrahhal commented 5 years ago

😞😞😞

RedaAouad commented 4 years ago

Hello @mrahhal Any news on this? Any announced or predicted time frame? I'm stuck with .net core 2.2 because of it, and it's end of life.

mrahhal commented 4 years ago

Hello @RedaAouad

Almost no way this can work anymore, sorry 😞

But I think there's a way by using a new official tool called ef6.exe directly.

You do this by updating your EntityFramework version to 6.4.0. After you do, this ef6.exe tool will be at "%USERPROFILE%\.nuget\packages\EntityFramework\6.4.0\tools\net45\any\ef6.exe".

This means using this ef6.exe instead of dotnet ef6 .... But it's a bit different. It needs an "--assembly" option. Something like this might work (terminal inside the proj that has the models):

C:\Users\[username]\.nuget\packages\entityframework\6.4.0\tools\net45\any\ef6.exe migrations list --assembly bin\Debug\[tfm]\[AppProj].dll

Here is its source: https://github.com/dotnet/ef6/tree/master/src/ef6. But for some reason I can't find documentation for it.

mrahhal commented 4 years ago

@RedaAouad let me know if that ends up working for you.

RedaAouad commented 4 years ago

It works fine. You should also add --project-dir . option.

X:\path\to\models\project > C:\Users\[username]\.nuget\packages\entityframework\6.4.0\tools\net45\any\ef6.exe migrations list --assembly bin\Debug\[tfm]\[AppProj].dll --project-dir .

Also, thanks for the tip about the need to have a models project that has no dependencies on anything aspnetcore-related. Otherwise, the ef6.exe tool throws.

Ref: https://github.com/mrahhal/Migrator.EF6/blob/master/README.md

IMPORTANT: it's highly recommended that you put your models and migrations in a pure class library project that has no dependnecies on anything aspnetcore related. Apart from being a better design, there's actually a current problem that prevents the tool from working with projects that depend on aspnetcore. And the new tooling in v0.1 fully supports that. For more info check this issue.

Thanks πŸ‘

marchy commented 4 years ago

Great stuff guys!

We ended up going down the path of porting over our models into EF Core side-by-sides (probably something worth its own blog post) as we couldn't get ourselves unstuck from this.

We ended up moving everything to a '.OLD' namespace and mapping everything from scratch in EF Core as to make the migration scripts match the existing EF6 tables perfectly. This ended up working for everything other than TPT-related tables/entities, which we left as being consumed only by EF6 models (ugly... but works).

With TPT finally out yesterday in, we can now proceed to take on the rest of the migration that was blocked off – and move life over fully to EF Core.

Hope when the time comes this helps! I don't think there will be any EF6 --> EF Core 'migration' migrations coming from the official MS team, so most likely this is what it'll have to be.

mrahhal commented 4 years ago

Uf, sounds tough. But good you got it working. Yeah I think it's best to just bite the bullet and try and migrate to EFCore when it's possible.

I don't think there will be any EF6 --> EF Core 'migration' migrations coming from the official MS team

Yeah, definitely won't happen if the past is anything to judge by πŸ˜… I'm just glad that there was at least an official ef6.exe that works.

I'll be closing this as this tool is now invalid for post .net core 2. Later I'll update the README to guide the move to ef6.exe. @marchy thank you for tagging along!