Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Getting Started guide does not work well #152

Open
eagle-k opened this issue Nov 30, 2022 · 3 comments
Open

The Getting Started guide does not work well #152

eagle-k opened this issue Nov 30, 2022 · 3 comments

Comments

@eagle-k
Copy link

eagle-k commented Nov 30, 2022

Describe the bug
Follow https://github.com/efcore/EFCore.FSharp/blob/master/GETTING_STARTED.md, and dotnet ef migrations add Initial fails.

Build started...
Build succeeded.
System.MissingMethodException: Method not found: 'System.String Microsoft.EntityFrameworkCore.Design.ICSharpHelper.Fragment(Microsoft.EntityFrameworkCore.Design.MethodCallCodeFragment, System.String, Boolean)'.
   at EntityFrameworkCore.FSharp.EFCoreFSharpServices.Microsoft.EntityFrameworkCore.Design.IDesignTimeServices.ConfigureDesignTimeServices(IServiceCollection services)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureDesignTimeServices(Type designTimeServicesType, IServiceCollection services)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureReferencedServices(IServiceCollection services, String provider)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.CreateServiceCollection(DbContext context)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(DbContext context)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Method not found: 'System.String Microsoft.EntityFrameworkCore.Design.ICSharpHelper.Fragment(Microsoft.EntityFrameworkCore.Design.MethodCallCodeFragment, System.String, Boolean)'.

To Reproduce
I will share the actual repository where the error occurred.
https://github.com/eagle-k/FsEfTest

Expected behavior
dotnet ef migrations add Initial succeeds.

Desktop (please complete the following information):

  • OS: Windows 10
  • .NET CLI Version 7.0.100
  • Entity Framework Core .NET Command-line Tools 7.0.0
  • Paket version 7.2.0+bb14ab674b2748070a624f394cd6796e11aaffa8

Additional context

dotnet ef dbcontext info succeeds.

Build started...
Build succeeded.
Type: BloggingModel+BloggingContext
Provider name: Microsoft.EntityFrameworkCore.Sqlite
Database name: main
Data source: blogging.db
Options: None
@teves-castro
Copy link

Also trying to test this int a net7.0 project without success.
As far as I understand this library was compiled with a reference to Microsoft.EntityFrameworkCore.Design 6.0 which seems to not be compatible with Entity Framework 7.

@Yury-Zakharov
Copy link

What I have found recently:
The error described has nothing to do with dotnet-ef tool installed - it fails equally with version 7 and 6.
It also has nothing to do (directly) with your project target version, fails both with .net7 and .net6
What really matters is the version of Microsoft.EntityFrameworkCore nuget package used in your project.
I downgraded mine to 6.0.13 and the command 'dotnet ef migrations add' works like a charm.
I have not changed the version of EFCore.FSharp though, as it's built with EntityFrameworkCore v6.0
As a workaround this downgrade works, in theory you can downgrade, add migrations and upgrade again but this way is a bit risky to me, there are some breaking changes in EF Core since 6.0 and one day they'll bite me.

Further investigation shows that one of the breaking changes in EF Core is in 'ICSharpHelper' , namely 'ICSharpHelper.Fragment'. ave not looked deeper, whether it's changed or removed or moved somewhere else, not sure.

Would be nice to see the fix in EFCore.FSharp soon. I could help within my humble knowledge, but, realistically, not much :)

@EspenBrun
Copy link
Contributor

EspenBrun commented Jul 28, 2023

I also had this problem, and manually editing the paket.lock file to target 6.0.13 for Microsoft.EntityFrameworkCore and other dependencies that where targeting 7.0.9 on my machine. Just did a search an replace. My paket.lock diff after changes:

diff --git a/paket.lock b/paket.lock
index 870c228..3b86826 100644
--- a/paket.lock
+++ b/paket.lock
@@ -5,30 +5,30 @@ NUGET
       Microsoft.EntityFrameworkCore.Design (>= 6.0) - restriction: >= net6.0
     FSharp.Core (6.0.7)
     Humanizer.Core (2.14.1) - restriction: >= net6.0
-    Microsoft.Data.Sqlite.Core (7.0.9) - restriction: >= net6.0
+    Microsoft.Data.Sqlite.Core (6.0.13) - restriction: >= net6.0
       SQLitePCLRaw.core (>= 2.1.4) - restriction: >= netstandard2.0
-    Microsoft.EntityFrameworkCore (7.0.9) - restriction: >= net6.0
-      Microsoft.EntityFrameworkCore.Abstractions (>= 7.0.9) - restriction: >= net6.0
-      Microsoft.EntityFrameworkCore.Analyzers (>= 7.0.9) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore (6.0.13) - restriction: >= net6.0
+      Microsoft.EntityFrameworkCore.Abstractions (>= 6.0.13) - restriction: >= net6.0
+      Microsoft.EntityFrameworkCore.Analyzers (>= 6.0.13) - restriction: >= net6.0
       Microsoft.Extensions.Caching.Memory (>= 7.0) - restriction: >= net6.0
       Microsoft.Extensions.DependencyInjection (>= 7.0) - restriction: >= net6.0
       Microsoft.Extensions.Logging (>= 7.0) - restriction: >= net6.0
-    Microsoft.EntityFrameworkCore.Abstractions (7.0.9) - restriction: >= net6.0
-    Microsoft.EntityFrameworkCore.Analyzers (7.0.9) - restriction: >= net6.0
-    Microsoft.EntityFrameworkCore.Design (7.0.9) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore.Abstractions (6.0.13) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore.Analyzers (6.0.13) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore.Design (6.0.13) - restriction: >= net6.0
       Humanizer.Core (>= 2.14.1) - restriction: >= net6.0
-      Microsoft.EntityFrameworkCore.Relational (>= 7.0.9) - restriction: >= net6.0
+      Microsoft.EntityFrameworkCore.Relational (>= 6.0.13) - restriction: >= net6.0
       Microsoft.Extensions.DependencyModel (>= 7.0) - restriction: >= net6.0
       Mono.TextTemplating (>= 2.2.1) - restriction: >= net6.0
-    Microsoft.EntityFrameworkCore.Relational (7.0.9) - restriction: >= net6.0
-      Microsoft.EntityFrameworkCore (>= 7.0.9) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore.Relational (6.0.13) - restriction: >= net6.0
+      Microsoft.EntityFrameworkCore (>= 6.0.13) - restriction: >= net6.0
       Microsoft.Extensions.Configuration.Abstractions (>= 7.0) - restriction: >= net6.0
     Microsoft.EntityFrameworkCore.Sqlite (6.0.20)
       Microsoft.EntityFrameworkCore.Sqlite.Core (>= 6.0.20) - restriction: >= net6.0
       SQLitePCLRaw.bundle_e_sqlite3 (>= 2.1.2) - restriction: >= net6.0
-    Microsoft.EntityFrameworkCore.Sqlite.Core (7.0.9) - restriction: >= net6.0
-      Microsoft.Data.Sqlite.Core (>= 7.0.9) - restriction: >= net6.0
-      Microsoft.EntityFrameworkCore.Relational (>= 7.0.9) - restriction: >= net6.0
+    Microsoft.EntityFrameworkCore.Sqlite.Core (6.0.13) - restriction: >= net6.0
+      Microsoft.Data.Sqlite.Core (>= 6.0.13) - restriction: >= net6.0
+      Microsoft.EntityFrameworkCore.Relational (>= 6.0.13) - restriction: >= net6.0
       Microsoft.Extensions.DependencyModel (>= 7.0) - restriction: >= net6.0
     Microsoft.Extensions.Caching.Abstractions (7.0) - restriction: >= net6.0
       Microsoft.Extensions.Primitives (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants