Futures don't work with NET7, EF7
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)'.```
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
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.
Just upgraded and tested against a large test suite and everything passed. Thank you!
And it would be great if you could also release rc.1 version which was out today
Hello @virzak ,
We are already currently on it. My developer is currently modifying some code to be compatible with the RC1
Best Regards,
Jon
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 Everything passed! Awesome.
Hello again!
Great to hear everything is working as expected.
Don't hesitate to contact us if you need further assistance.
Best regards,
Jon