EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

Futures don't work with NET7, EF7

Open virzak opened this issue 3 years ago • 5 comments

1. Description

This code should execute normally, but crashes

using Microsoft.EntityFrameworkCore;
using Z.EntityFramework.Plus;

using var context = new MyContext();

context.Database.EnsureCreated();

var entity = new Entity { Id = Guid.NewGuid(), IsSomeBool = true };
context.Add(entity);
context.SaveChanges();

var future = context.Entities.Select(z => z.IsSomeBool).Future();
var future2 = context.Entities.Select(z => z.Id).Future();

var result = await future.ToArrayAsync();
var result2 = await future2.ToArrayAsync();

public class MyContext : DbContext
{
    public DbSet<Entity> Entities { get; set; } = default!;

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    => optionsBuilder
    .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Net7-Futures;Trusted_Connection=True");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
    }
}

public class Entity
{
    public Guid Id { get; set; }
    public bool IsSomeBool { get; set; }
}

2. Exception

System.Reflection.TargetInvocationException
  HResult=0x80131604
  Message=Exception has been thrown by the target of an invocation.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at .(IQueryable , Action`1 , RelationalQueryContext& , Object& )
   at Z.EntityFramework.Extensions.EFPlusExtensions.EFPlusCreateCommand(IQueryable source, Action`1 action, RelationalQueryContext& queryContext, Object& compiledQuery)
   at Z.EntityFramework.Plus.BaseQueryFuture.CreateExecutorAndGetCommand(RelationalQueryContext& queryContext)
   at Z.EntityFramework.Plus.QueryFutureBatch.CreateCommandCombined()
   at Z.EntityFramework.Plus.QueryFutureBatch.<ExecuteQueriesAsync>d__14.MoveNext()
   at Z.EntityFramework.Plus.QueryFutureEnumerable`1.<ToArrayAsync>d__5.MoveNext()
   at Program.<<Main>$>d__0.MoveNext() in Q:\Code\Sandbox\Net7-Futures\Net7-Futures\Program.cs:line 15

  This exception was originally thrown at this call stack:

Inner Exception 1:
MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Diagnostics.CoreLoggerExtensions.QueryExecutionPlanned(Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1<Query>, Microsoft.EntityFrameworkCore.Query.ExpressionPrinter, System.Linq.Expressions.Expression)'.```

virzak avatar Sep 01 '22 15:09 virzak

Hello @virzak ,

You are probably using the EF Core Preview 7, unfortunately, we still didn't have released a version compatible with this preview.

It should be released on September 13 but could also be one week later.

Best Regards,

Jon

JonathanMagnan avatar Sep 02 '22 14:09 JonathanMagnan

Hello @virzak ,

A new version has been released on Monday that it compatible with the preview 7

Could you try it and let us know if everything is working fine?

Best Regards,

Jon


Is this library useful to you? Please help us by becoming a sponsor to keep it alive and supported.

JonathanMagnan avatar Sep 14 '22 13:09 JonathanMagnan

Just upgraded and tested against a large test suite and everything passed. Thank you!

virzak avatar Sep 14 '22 13:09 virzak

And it would be great if you could also release rc.1 version which was out today

virzak avatar Sep 14 '22 13:09 virzak

Hello @virzak ,

We are already currently on it. My developer is currently modifying some code to be compatible with the RC1

Best Regards,

Jon

JonathanMagnan avatar Sep 14 '22 15:09 JonathanMagnan

Hello @virzak ,

A new version has been released today. We should now support RC1.

If you have the chance to test it, let us know if everything works as expected.

Best Regards,

Jon


Is this library useful to you? Please help us by becoming a sponsor to keep it alive and supported.

JonathanMagnan avatar Sep 26 '22 20:09 JonathanMagnan

@JonathanMagnan Everything passed! Awesome.

virzak avatar Sep 26 '22 20:09 virzak

Hello again!

Great to hear everything is working as expected.

Don't hesitate to contact us if you need further assistance.

Best regards,

Jon

JonathanMagnan avatar Sep 26 '22 20:09 JonathanMagnan