We are developing an Mobile app using Xamarin.Forms, which is backed by a Web app using ASP.NET Core. We load various models from databases on both the Web and Mobile apps, and recently we have transitioned to using EntityFramework Core (will refer to as EFCore) on the Web app.
We are currently looking at transitioning the Mobile app to also use the EFCore to allow us to share more code between the apps, but have run into problems with EFCore on iOS. It seems able to compile and run, and can load simple models, but fails to load nullable types which are used to specify optional relationships between models. This person seems to have EFCore running in iOS and provides a project for their code. I have pulled and ran the project myself to check it works, which it did, but after adding a nullable relation to his simple model, it subsequently failed to both load and create an item with this error:
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) :runtime_invoke_void__this___int_byte_byte_byte_byte_byte_object_object_object_object_object_object_object_object_object_object_Nullable1 (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
This error does not occur when running on the simulator, only on a device.
My question is whether anyone has had any success with getting Nullables working with EFCore on Xamarin iOS?
Many thanks, Will.
P.S. We are open to changing EFCore/Xamarin.iOS/Mono version to solve the problem.
This is a known issue. iOS has some limitations on generics, nullables... because Apple disallow code generation at runtime.
The issue is referenced on github for entity framework : Xamarin iOS : Crash when i add row to table with nullable type or with a lot of columns
And on Xamarin's bugzilla : BugÂ 58424 - Xamarin iOS : EF Core crash when I add row to table with nullable type or with a lot of columns