I am using Entity Framework Core 6 on an iOS application I built using .net6
. It used to work on older versions (both EF & .net) but now I am getting the following error:
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) AccountTableEntity
object:Thunk1ret_AccountTableEntity_QueryContext_DbDataReader_ResultContext_SingleQueryResultCoordinator (System.Func`2<object[], object>,Microsoft.EntityFrameworkCore.Query.QueryContext,System.Data.Common.DbDataReader,Microsoft.EntityFrameworkCore.Query.Internal.ResultContext,Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryResultCoordinator)' while running in aot-only mode.
See https://learn.microsoft.com/xamarin/ios/internals/limitations for more information.
I am not sure why it would be failing considering how simple the use case is. Here is the TableEntity:
[Table("Accounts")]
internal sealed class AccountTableEntity
{
/// <summary>
/// Gets or sets the data.
/// </summary>
[Column("Data")]
public string Data { get; set; }
/// <summary>
/// Gets or sets the ID of the owner of the account.
/// </summary>
[Column("UserSid")]
public string UserSid { get; set; }
public AccountTableEntity()
{
UserSid = string.Empty;
Data = string.Empty;
}
/// <param name="accountTableEntity"></param>
/// <exception cref="ArgumentNullException">
/// Thrown if:
/// - The instance of <see cref="AccountTableEntity" /> is not specified.
/// </exception>
public AccountTableEntity(AccountTableEntity accountTableEntity)
{
Guard.Argument(accountTableEntity, nameof(accountTableEntity)).NotNull();
UserSid = accountTableEntity.UserSid;
Data = accountTableEntity.Data;
}
}
And here is the call :
DbContext db = ...;
foreach (AccountTableEntity account in db.Accounts.ToList())
{
//
}
By looking at the callstack and my pretty straightforward use case, I am getting the feeling that EFCore 6 does not work on iOS anymore.
Question
Can Entity Framework Core 6 work on iOS and if yes, why is it failing now with an System.ExecutionEngineException
?