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

Workarounds for Xamarin.iOS app with EFCore 2.0 #597

Open
bricelam opened this issue Jan 5, 2018 · 10 comments
Open

Workarounds for Xamarin.iOS app with EFCore 2.0 #597

bricelam opened this issue Jan 5, 2018 · 10 comments

Comments

@bricelam
Copy link
Contributor

bricelam commented Jan 5, 2018

Updated to current known issues and workarounds:

Good sample app link applying workarounds by @cwrea: https://github.com/cwrea/XamarinTodo/tree/master

Original Issue:

From @alexdrl on November 21, 2017 8:44

A Xamarin.iOS app with EFCore 2.0 needs a call to

SQLitePCL.Batteries_V2.Init();

If the call is not made, the app initialization throws this error message.

You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().

Like explained here

Steps to reproduce

Xamarin.iOS project working with EFCore 2.0. Solution with a common .NET Standard project which shares code between iOS and Android, using PackageReference.

Further technical details

EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: iOS
IDE: Visual Studio 15.4

Copied from original issue: dotnet/efcore#10361

@bricelam
Copy link
Contributor Author

bricelam commented Jan 5, 2018

Correct. I don't think Xamarin.iOS can handle the Assembly.Load() call. And binding directly to SQLitePCLRaw.batteries_v2.dll will cause problems if you're not using a bundle.

@bricelam
Copy link
Contributor Author

bricelam commented Jan 5, 2018

From @alexdrl on November 22, 2017 18:27

I use the SQLitePCLraw assembly that gets added as a transitive dependency, and call that Init method, the app works correctly. In the project assets json, the Xamarin.iOS SQLitePCLraw package gets restored correctly.

@bricelam
Copy link
Contributor Author

bricelam commented Jan 5, 2018

We should probably document this on the Supported .NET Implementations page or thereabouts.

@bricelam
Copy link
Contributor Author

bricelam commented Jan 5, 2018

From @alexdrl on November 22, 2017 18:31

The documentation already stated that there are problems in Xamarin.iOS but there is no page that describes this (or other) workarounds.

@bricelam bricelam added this to the 2.1.0 milestone Jan 5, 2018
@divega divega changed the title Xamarin.iOS app with EFCore 2.0 SQLitePCL.Batteries.Init() Workarounds for Xamarin.iOS app with EFCore 2.0 Mar 24, 2018
@cwrea
Copy link

cwrea commented Jun 13, 2018

Worth noting here, with respect to the Entity Framework Core 2.1 release, and the Visual Studio 15.7.3 releases of Xamarin.iOS and Xamarin.Android:

At present, the only known workaround for Xamarin mobile app developers wishing to use Entity Framework Core is to not upgrade to the 2.1 release. i.e. Stay on 2.0.3 until the underlying Xamarin platforms have addressed deficiencies related to the new System.Memory 4.5 dependency that was introduced (indirectly) as part of the newer packages that EF Core 2.1 now depends on. I am not aware of any timeline with respect to when these issues may be fixed.

@dfoulk
Copy link

dfoulk commented Jun 21, 2018

@cwrea Thank you for mentioning this. I would've spent hours debugging that issue if I hadn't seen your comment first! Literally saved us hundreds of dollars!

@cwrea
Copy link

cwrea commented Jun 21, 2018

@dfoulk You're welcome. FWIW, since I posted that, there's hope that Visual Studio 15.8 Preview 3 may address these issues. See my comment from a couple of days ago at xamarin/xamarin-macios#4168 (comment) ... I haven't tried the preview myself, yet. Tied up in other project work at the moment.

@Pinox
Copy link

Pinox commented Jun 22, 2018

@cwrea very weird. I'm running ef core 2.1 on my android and native UWP and it works and builds fine (debug and release) , but I'm using Microsoft.Extentions.primitives version 2.0

@cwrea
Copy link

cwrea commented Jun 22, 2018

@Pinox Do you have linking enabled? The oustanding Android issue is specific to having linking enabled.

@Pinox
Copy link

Pinox commented Jun 22, 2018

@cwrea In release mode I have "SDK Assemblies" and in debug mode "none".

Edit
Ignore my comments as this morning my projects also do not work anymore with ef core 2.1

@divega divega modified the milestones: 2.1.0, 2.2.0 Jul 10, 2018
@divega divega modified the milestones: 2.2.0, 3.0.0 Feb 21, 2019
@bricelam bricelam removed their assignment Aug 23, 2019
@ajcvickers ajcvickers removed this from the 3.0.0 milestone Aug 28, 2019
@divega divega added this to the Backlog milestone Sep 9, 2019
@bricelam bricelam mentioned this issue Nov 11, 2019
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants