dotnet / dotnet/EntityFramework.Docs
Workarounds for Xamarin.iOS app with EFCore 2.0
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
## Updated to current known issues and workarounds:
- ~~For Xamarin.Android, use package.config instead of PackageReference (dependent on https://github.com/xamarin/xamarin-android/issues/1196).~~
- For Xamarin.Android, try changing AndroidLinkMode to SdkOnly ( https://github.com/aspnet/EntityFrameworkCore/issues/11027#issuecomment-374425403) or other workarounds to preserve additional reflection metadata, e.g. `[assembly: Preserve (typeof (System.Linq.Queryable), AllMembers = true)]` (dependent on https://github.com/aspnet/EntityFrameworkCore/issues/10963) or using a [LinkDescription.xml]( https://github.com/cwrea/XamarinTodo/blob/master/Todo.Android/LinkDescription.xml) file.
- For SQLite, use `SQLitePCL.Batteries_V2.Init()` (see https://github.com/ericsink/SQLitePCL.raw/wiki/SQLitePCL.Batteries.Init).
- Tooling is blocked on the fact that the linker used by Xamarin removes assembly level attributes (see https://github.com/xamarin/xamarin-macios/issues/3655).
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
```c#
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](https://github.com/ericsink/SQLitePCL.raw/wiki/SQLitePCL.Batteries.Init)
### 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: aspnet/EntityFrameworkCore#10361_
Contributor guide
Assessment
This issue has not been assessed yet.