Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS cannot save Entity models with Nullable Guid (Guid?) property types (among others) using EF Core 2.1.2. #10483

Closed
rolfbjarne opened this issue Sep 6, 2018 · 24 comments

Comments

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @cfdelaune on September 4, 2018 21:39

Steps to Reproduce

  1. Download, extract, and load the sample solution in Visual Studio 15.8.1.
    iOSEFCore212.zip

  2. Build and run the project, targeting a physical iPhone device.

PLEASE NOTE: This project has been adapted from the sample provided by @cwrea for a preceding issue described here.

Expected Behavior

The project should build and run, writing some lines to debug output indicating that Entity Framework Core has created a database from the simple model included in the project, saved a few test records, and retrieved them.

Actual Behavior

The following exception is encountered when AddAsync() is called against the DbSet:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_byte_object_object_DateTime_Nullable1<DateTime>_Decimal_Guid_Nullable1<Guid>_Nullable1<int> (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information. occurred

If the model (TodoItem.cs) does not contain a property of type Guid?, the project works without issue. Note that DateTime?, int?, and bool? property types work, but a similar error will be encountered for the decimal? type. I have not tested any additional nullable types at this time.

This issue is similar to https://bugzilla.xamarin.com/show_bug.cgi?id=58424 and https://bugzilla.xamarin.com/show_bug.cgi?id=59184, both of which have been marked as RESOLVED FIXED. I have submitted this per the suggestion of @divega.

Environment

Microsoft Visual Studio Professional 2017 
Version 15.8.1
VisualStudio.15.Release/15.8.1+28010.2003
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Professional

ActiveReports 11   11.2.12190.0
The first report writer for Microsoft .NET

ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools

Application Insights Tools for Visual Studio Package   8.13.10627.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.8.05074.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2012   4.0.30625.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017   5.2.60618.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.8.05023.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.4000.4
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   15.8.05023.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.3.4000.4
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   2.9.0-beta8-63208-01
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

JavaScript Language Service   2.0
JavaScript Language Service

JetBrains ReSharper Ultimate 2018.1.4    Build 112.0.20180731.142027
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2018 JetBrains, Inc.

Merq   1.1.38 (5b3c069)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.3.4000.4
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.4000.4
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   2.3
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.3.4000.4
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10730.2

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio   4.11.7-pre (8955b2a)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61808.07020
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   15.8.20801.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.9.0-beta8-63208-01
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.2 for F# 4.5   15.8.0.0.  Commit Hash: c55dd2c3d618eb93a8d16e503947342b1fa93556.
Microsoft Visual F# Tools 10.2 for F# 4.5

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   4.11.0.732 (d15-8@33e83e124)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.14.218 (79f535bdd)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   1.1.113 (e1d02a7)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   9.0.0.18 (HEAD/3d8a28f1a)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.14.0.13 (373c313)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

The project builds without issue.

Example Project (If Possible)

iOSEFCore212.zip

Copied from original issue: xamarin/xamarin-macios#4749

@rolfbjarne rolfbjarne added bug labels Sep 6, 2018
@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @mauruskuehne on September 5, 2018 6:54

We have this problem too in our app. @cfdelaune do you have a workaround for this until it's fixed?

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @cfdelaune on September 5, 2018 11:46

Unfortunately, no. I have been fighting with this problem for months. Until VS 2017 15.7.6, I could not even compile, so I am just now able to identify the specific problem.

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @ysmoradi on September 5, 2018 16:52

The workaround is here! https://github.com/ysmoradi/EfCoreiOSIssue/
@cfdelaune @mauruskuehne @cwrea @1saeedsalehi

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @divega on September 5, 2018 22:59

@rolfbjarne can you please provide more information about what specific limitation in Xamarin iOS this is hitting?

Also, any chance this can be re-prioritized? We have been getting lots of feedback from Xamarin customers trying to use EF Core and we have been working through issues with several people in the Xamarin team, trying to get things to a place in which we can claim it is usable and a good experience.

And it seems we are getting so close! But having something like this lingering in the "Future" milestone could cause a lot of pain.

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @ysmoradi on September 6, 2018 9:39

@divega I've used ef core in many xamarin based projects. I've experienced 3 pains. 1- Poor performance on android devices, 2- sqlite migrations limitations and this issue. You're generating code at runtime using lambda expressions (NewExpression + Compile), and this violates iOS limitations. You may not generate code at runtime in iOS apps. I think you've used that feature to improve overall performance in some scenarios. Xamarin iOS has some workarounds for code generations at runtime and not every code generation results into exception. But when you talk about generics (Nullable for example), you can encounter a problem far easier!

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

From @mandel-macaque on September 6, 2018 9:42

Here is some extra information. I have been able to reproduce the bug with Xamarin.iOS 11.14.0.13 (373c313), which is the one used to report the issue. I have also tested the following environments:

-Latests stable Wit a successful build which is successful when running the application on a device it crashes.

-Beta channel Similar build success.

-Alpha channel The build fails with an unrelated issue.

-Xcode 10 branch Application also builds with no errors And like the others, app crashes.

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

@ysmoradi I'm not sure which limitation this is hitting, it might just be a bug too. I'll have to forward this to the mono team for them to have a look at it.

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

Due to xamarin/xamarin-macios#4761 the project does not build with a Xamarin.iOS version that uses mono 2018-04 (for instance our master or d15-9 branches).

To reproduce, use either a stable version of Xamarin.iOS (d15-8), or the mono-2018-06 branch (PR xamarin/xamarin-macios#4277)

@marek-safar

This comment has been minimized.

Copy link
Member

@marek-safar marek-safar commented Sep 6, 2018

@vargaz this is another Nullable<> case but it's quite short. Could you check why we cannot expand it?

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Sep 6, 2018

Application output from one of the times I reproduced it: https://gist.github.com/rolfbjarne/79410870f955f9a322574d1a53a698b3

vargaz added a commit to vargaz/mono that referenced this issue Sep 7, 2018
monojenkins added a commit to monojenkins/mono that referenced this issue Sep 10, 2018
monojenkins added a commit to monojenkins/mono that referenced this issue Sep 10, 2018
marek-safar added a commit that referenced this issue Sep 11, 2018
marek-safar added a commit that referenced this issue Sep 11, 2018
@marek-safar marek-safar added this to the 2018-06 (5.16.xx) milestone Sep 24, 2018
jonpryor added a commit to xamarin/xamarin-android that referenced this issue Oct 9, 2018
Bumps to mono/llvm:release_60@117a508c
Bumps to xamarin/xamarin-android-api-compatibility:master@7ccb4802

	$ git diff --shortstat e1af6ea..ab3c897d       # mono
        1443 files changed, 66049 insertions(+), 45745 deletions(-)
	$ git diff --shortstat bdb3a116..117a508c      # llvm
	 26794 files changed, 4110589 insertions(+), 754376 deletions(-)
	$ git diff --shortstat c550d1bd..7ccb4802      # xamarin-android-api-compatibility
	 2 files changed, 16260 insertions(+), 12347 deletions(-)

Incomplete summary of easily `grep`able fixes:

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=11199
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=19436
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=23668
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=26983
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=33728
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=46917
fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60065
Fixes: mono/mono#6173
Fixes: mono/mono#6466
Fixes: mono/mono#6647
Fixes: mono/mono#6834
Fixes: mono/mono#7058
Fixes: mono/mono#7137
Fixes: mono/mono#7260
Fixes: mono/mono#7305
Fixes: mono/mono#7402
Fixes: mono/mono#7525
Fixes: mono/mono#7610
Fixes: mono/mono#7649
Fixes: mono/mono#7655
Fixes: mono/mono#7683
Fixes: mono/mono#7685
Fixes: mono/mono#7716
Fixes: mono/mono#7731
Fixes: mono/mono#7785
Fixes: mono/mono#7828
Fixes: mono/mono#7944
Fixes: mono/mono#7947
Fixes: mono/mono#8036
Fixes: mono/mono#8074
Fixes: mono/mono#8089
Fixes: mono/mono#8112
Fixes: mono/mono#8122
Fixes: mono/mono#8143
Fixes: mono/mono#8149
Fixes: mono/mono#8152
Fixes: mono/mono#8175
Fixes: mono/mono#8177
Fixes: mono/mono#8250
Fixes: mono/mono#8267
Fixes: mono/mono#8273
Fixes: mono/mono#8282
Fixes: mono/mono#8310
Fixes: mono/mono#8311
Fixes: mono/mono#8329
Fixes: mono/mono#8340
Fixes: mono/mono#8372
Fixes: mono/mono#8407
Fixes: mono/mono#8409
Fixes: mono/mono#8422
Fixes: mono/mono#8430
Fixes: mono/mono#8439
fixes: mono/mono#8447
Fixes: mono/mono#8469
Fixes: mono/mono#8504
Fixes: mono/mono#8575
Fixes: mono/mono#8597
Fixes: mono/mono#8623
Fixes: mono/mono#8627
Fixes: mono/mono#8698
Fixes: mono/mono#8701
Fixes: mono/mono#8712
Fixes: mono/mono#8721
Fixes: mono/mono#8726
Fixes: mono/mono#8759
Fixes: mono/mono#8787
Fixes: mono/mono#8820
Fixes: mono/mono#8848
Fixes: mono/mono#8866
Fixes: mono/mono#8897
Fixes: mono/mono#8915
Fixes: mono/mono#8970
Fixes: mono/mono#8979
Fixes: mono/mono#9023
Fixes: mono/mono#9031
Fixes: mono/mono#9033
Fixes: mono/mono#9179
Fixes: mono/mono#9234
Fixes: mono/mono#9262
Fixes: mono/mono#9277
Fixes: mono/mono#9318
Fixes: mono/mono#9542
Fixes: mono/mono#9753
Fixes: mono/mono#9839
Fixes: mono/mono#9869
Fixes: mono/mono#9870
Fixes: mono/mono#9943
Fixes: mono/mono#9996
Fixes: mono/mono#10000
Fixes: mono/mono#10303
Fixes: mono/mono#10447
Fixes: mono/mono#10483
Fixes: mono/mono#10488
Fixes: xamarin/maccore#628
Fixes: xamarin/maccore#673
Fixes: #1561 (comment)
Fixes: #1845
Fixes: xamarin/xamarin-macios#4347
Fixes: xamarin/xamarin-macios#4617
Fixes: xamarin/xamarin-macios#4618
@Dabbel

This comment has been minimized.

Copy link

@Dabbel Dabbel commented Oct 17, 2018

Bug still seems to exists, try with sample project i attached. EFCoreXamarinBug.zip

Mono 5.16.0.173

@lewurm

This comment has been minimized.

Copy link
Member

@lewurm lewurm commented Oct 18, 2018

@Dabbel you need to update Xamarin.iOS. Mono 5.16.0.173 is the version of your system mono (that's different to to mono version that is packaged with Xamarin.iOS). What Version of Xamarin.iOS are you using?

@Dabbel

This comment has been minimized.

Copy link

@Dabbel Dabbel commented Oct 19, 2018

@lewurm 12.2.0.26

i'm using the current beta channel of visual studio for mac

@lewurm

This comment has been minimized.

Copy link
Member

@lewurm lewurm commented Oct 19, 2018

@Dabbel it hasn't made it into that release. As far as I can tell the earliest is 12.5.1.14; this is current master and not considered stable. You can grab builds from it by going here https://github.com/xamarin/xamarin-macios/commits/master and click on the green checkmark, but it's not recommended 🙂

@rolfbjarne should we backport this fix to 2018-04?

@Dabbel

This comment has been minimized.

Copy link

@Dabbel Dabbel commented Oct 19, 2018

@lewurm with 12.5.1.14 my usecase works

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Oct 19, 2018

@Dabbel if it works for you, feel free to continue using it.

@lewurm I doubt we'll backport this to d15-9, so it's enough to have it in 2018-06, and it'll get into the next d16-0 preview.

@YZahringer

This comment has been minimized.

Copy link

@YZahringer YZahringer commented Nov 3, 2018

In which version of Visual Studio will it released? The last update VS 7.6.11.9 include Xamarin.iOS 12.1.0.15.

@YZahringer

This comment has been minimized.

Copy link

@YZahringer YZahringer commented Nov 16, 2018

The error persists on last update Xamarin.iOS 12.2.1.10

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Nov 19, 2018

@YZahringer we haven't released this fix yet, it will be included in the first d16.0 preview (which should be released in early December).

jonpryor added a commit to xamarin/xamarin-android that referenced this issue Dec 6, 2018
Bumps to mono/api-snapshot@b99fc87.
Bumps to mono/bockbuild@5af573e.
Bumps to mono/boringssl@41221b4.
Bumps to mono/corefx@23d0b58.
Bumps to mono/corert@af496fc.
Bumps to mono/linker@7af03ce.
Bumps to mono/NUnitLite@00e259a.
Bumps to mono/reference-assemblies@9325826.
Bumps to mono/roslyn-binaries@249709f.
Bumps to mono/xunit-binaries@bb58347.

	$ git diff --shortstat b63e5378..23f2024a      # mono 
	 1630 files changed, 50926 insertions(+), 92212 deletions(-)

Fixes: mono/mono#6352
Fixes: mono/mono#6947
Fixes: mono/mono#6992
Fixes: mono/mono#7615
Fixes: mono/mono#8340
Fixes: mono/mono#8407
Fixes: mono/mono#8575
Fixes: mono/mono#8627
Fixes: mono/mono#8707
Fixes: mono/mono#8766
Fixes: mono/mono#8848
Fixes: mono/mono#8866
Fixes: mono/mono#8935
Fixes: mono/mono#9010
Fixes: mono/mono#9023
Fixes: mono/mono#9031
Fixes: mono/mono#9033
Fixes: mono/mono#9106
Fixes: mono/mono#9109
Fixes: mono/mono#9155
Fixes: mono/mono#9179
Fixes: mono/mono#9232
Fixes: mono/mono#9234
Fixes: mono/mono#9262
Fixes: mono/mono#9277
Fixes: mono/mono#9292
Fixes: mono/mono#9318
Fixes: mono/mono#9318
Fixes: mono/mono#9332
Fixes: mono/mono#9407
Fixes: mono/mono#9421
Fixes: mono/mono#9505
Fixes: mono/mono#9542
Fixes: mono/mono#9581
Fixes: mono/mono#9623
Fixes: mono/mono#9684
Fixes: mono/mono#9750
Fixes: mono/mono#9753
Fixes: mono/mono#9772
Fixes: mono/mono#9839
Fixes: mono/mono#9869
Fixes: mono/mono#9921
Fixes: mono/mono#9943
Fixes: mono/mono#9947
Fixes: mono/mono#9973
Fixes: mono/mono#9996
Fixes: mono/mono#10000
Fixes: mono/mono#10031
Fixes: mono/mono#10035
Fixes: mono/mono#10227
Fixes: mono/mono#10243
Fixes: mono/mono#10303
Fixes: mono/mono#10448
Fixes: mono/mono#10483
Fixes: mono/mono#10488
Fixes: mono/mono#10863
Fixes: mono/mono#11123
Fixes: mono/mono#11138
Fixes? mono/mono#11146
Fixes: mono/mono#11202
Fixes: mono/mono#11378
Fixes: mono/mono#11479
Fixes: mono/mono#11613
Fixes: #1951
Fixes: xamarin/xamarin-macios#4347
Fixes: xamarin/xamarin-macios#4617
Fixes: xamarin/xamarin-macios#4984
@YZahringer

This comment has been minimized.

Copy link

@YZahringer YZahringer commented Dec 10, 2018

I tried with Visual Studio 2019 Preview 1.0 for Windows and Mac, the error persists. I see that Xamarin.iOS on Mac is still in version 12.2.1.11 d15-9.

Wait for the release of Visual Studio 2019, in Q1/Q2 2019 to make Entity Framework Core work on Xamarin is too long, Is not possible to merge this fix to VS 2017?

@ysmoradi

This comment has been minimized.

Copy link

@ysmoradi ysmoradi commented Dec 23, 2018

@YZahringer we haven't released this fix yet, it will be included in the first d16.0 preview (which should be released in early December).

I've installed vs 2019 + xamarin ios 12.3 on both windows & mac. The same exception is thrown )-:

@ysmoradi

This comment has been minimized.

Copy link

@ysmoradi ysmoradi commented Dec 23, 2018

It seems it's working fine in interpreter mode! ;D
@1saeedsalehi

@Dabbel

This comment has been minimized.

Copy link

@Dabbel Dabbel commented Jan 28, 2019

@lewurm @rolfbjarne
Any news when it is released in an official release (not preview or anything else like that). We have plenty of customers who want to use Xamarin.Forms on iOS but the only thing we can tell them is that Microsoft hasn't released the fix for more then a year. I say year because there are many tickets like that with the same error only for different types.

And i don't think that we are the only company that need the fix in a release version to satisfy the needs of their customers.

@rolfbjarne

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne commented Jan 28, 2019

Any news when it is released in an official release (not preview or anything else like that).

The stable release of d16.0/VS2019 will probably be in March/April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.