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. #4749

Closed
cfdelaune opened this issue Sep 4, 2018 · 8 comments
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS
Milestone

Comments

@cfdelaune
Copy link

cfdelaune commented Sep 4, 2018

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

@mauruskuehne
Copy link

mauruskuehne commented Sep 5, 2018

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

@cfdelaune
Copy link
Author

cfdelaune commented Sep 5, 2018

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 rolfbjarne added this to the Future milestone Sep 5, 2018
@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS labels Sep 5, 2018
@ysmoradi
Copy link

ysmoradi commented Sep 5, 2018

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

@divega
Copy link

divega commented Sep 5, 2018

@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.

@ysmoradi
Copy link

ysmoradi commented Sep 6, 2018

@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!

@mandel-macaque
Copy link
Member

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
Copy link
Member

@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
Copy link
Member

This issue was moved to mono/mono#10483

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS
Projects
None yet
Development

No branches or pull requests

6 participants