EntityFramework.Extended Future error (JIT Compiler internal limitation)
Asked Answered
L

2

16

I am working with Code First EntityFramework (version="6.1.0") and EntityFramework.Extended (version="6.1.0.96, the latest build at the moment from here.
The DbContext exposes the DbSets which are accessed like:

var set = ctx.Set<MyEntity>();

Today I decided to try Future Queries of the EntityFramework.Extended library, and ended pretty much soon, without an idea of how to proceed.

Here is the sample code:

using (var ctx = new MyDbContext())
{              
    var u = ctx.Set<User>().Future();
    var c = ctx.Set<Country>().Future();
    var users = u.ToList();
}

Regarding the Future() documentation I should get only one query to the DB which is what the Future() method provides. The query should be launched at u.ToList(); but what happens is that I get an error like this:

JIT Compiler encountered an internal limitation.

A stack trace dive tells me this:

at EntityFramework.Future.FutureQueryBase 1.GetResult()

at EntityFramework.Future.FutureQuery 1.GetEnumerator()

at System.Collections.Generic.List 1..ctor(IEnumerable 1 collection)

at System.Linq.Enumerable.ToList[TSource](IEnumerable 1 source)

at App.Program.Main(String[] args) in c:\Users\...\App\Program.cs:line 25

I really don't know what I'm missing out. I've checked that my ConnectionString has MultipleResultSets set to TRUE.
I've tested this with earlier build releases of EF.Exteneded but the same error occured.

Any idea would greatly help.

Layamon answered 24/4, 2014 at 13:51 Comment(10)
seems to be related to https://mcmap.net/q/821448/-servicestack-ormlite-system-invalidprogramexception-jit-compiler-encountered-an-internal-limitationStreusel
@Streusel checked that out, but no progress, I will do check now, maybe after some updates progress was made... Thank you for the feedback.Paleolith
@VedranMandić I'm sure that you don't have this problem anymore, but: This error usually happens when JIT is compiling IL that is faulty in some was (bad types on the stack etc.). I'm not very familiar with EntityFramework.Extended but I would expect that it is doing exactly that.Beeline
did you try removing and re-adding EF via nuget. ?Firework
@philsoady yup, first thing I tried. I even tried older versions. Well, honestly I did not find time to test this, I really believe Daniel Balas was right with the previous comment.Paleolith
Did you look at this lostechies.com/jimmybogard/2014/03/11/…Brietta
Can you post codes of the User and Country classes as well?Quadrille
@T.Rahgooy that's irrelevant, they're POCOs, i.e. take for e.g. a spec with 2 props like: int ID and string Name in both.Paleolith
I did test your code with simple POCOs that have Id and Name props , and there wasn't any problem. Did you tried to make a new project and test it from scratch?Quadrille
Try Installing Entity Framework 6.1.3Donica
L
0

So to add up after one year later; updated the Entity Framework to the latest version 6.1.3, installed the latest EntityFramework.Extended library, and one thing to note is I've used the 'Database first' approach for the test and all went OK. Could've been other strange stuff out of my control then.

Thanks everyone for the support on this one.

Layamon answered 12/9, 2015 at 8:16 Comment(0)
M
0

Could be wrong, but I think

ctx.Set<User>() 

returns a DBSet whereas .Future() is supposed to be used at the end of queries. Maybe if you append .AsQueryable to the end of ctx.Set()?

ctx.Set<User>().AsQueryable().Future()

Also I think you can just use ctx.users if you have your EF database built that way.

Melanesian answered 10/9, 2015 at 19:43 Comment(1)
I won't give -1 to this, but note this: 'public interface IDbSet<TEntity> : IQueryable<TEntity>, IEnumerable<TEntity>, IQueryable, IEnumerable where TEntity : class', so no need for AsQueryable(). Also, I cleaned my .tt file from generating named variables such as users, so ctx in this case dose not contain that, i.e. all DbSets (as that what they are) can be accessed over .Set<TEntityClass>. Thank you for the effort.Paleolith
L
0

So to add up after one year later; updated the Entity Framework to the latest version 6.1.3, installed the latest EntityFramework.Extended library, and one thing to note is I've used the 'Database first' approach for the test and all went OK. Could've been other strange stuff out of my control then.

Thanks everyone for the support on this one.

Layamon answered 12/9, 2015 at 8:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.