0

I used Entity Framework Core in one of my Xamarin Android apps. When I use SDK only as of the linker option then the app works properly.

However, when I use SDK and user assemblies add linker option, the app crashes as several Entity Framework Core related required classes are removed by the linker.

Let me know if there is anything I could do to preserve the classes.

Note: I already tried referencing the Entity Framework Core classes in a dummy class.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
  • Hi Sushi, thanks. The linker removed the classes present in the entity framework core DLLs so not sure whether we could use preserve keyword to notify linker about it. – Tushar Koshti May 18 '19 at 04:31
  • Skip link section: https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker#linkskip – SushiHangover May 18 '19 at 04:36

2 Answers2

0

You have to configure the linker.

  • Create a new xml in your Android project, call it linker.xml
  • Set the build action to LinkDescription
  • Paste this code:
    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
      <assembly fullname="mscorlib">
        <type fullname="System.String">
          <method name="Compare"></method>
          <method name="CompareTo"></method>
          <method name="ToUpper"></method>
          <method name="ToLower"></method>
        </type>
      </assembly>
      <assembly fullname="System.Core">
        <type fullname="System.Linq.Expressions.Expression`1"></type>
        <type fullname="System.Linq.Queryable"></type>
      </assembly>
    </linker>

More complex usage of EF Core is likely to require a few more types and methods added.

GiampaoloGabba
  • 1,428
  • 1
  • 15
  • 21
0

Apparently my case is much more complex. I changes the file to

  <linker>
     <assembly fullname="mscorlib">
        <type fullname="System.String" />
     </assembly>
     <assembly fullname="System.Core">
        <type fullname="System.Linq.Expressions*" />
        <type fullname="System.Linq.Queryable*" />
     </assembly>
     <assembly fullname="System.Collections">
        <type fullname="System.Collections.Generic*" />
     </assembly>
  </linker>

but it still didn't fix the issue. Did anybody figure out the complete exclusion list for the entity framework core to work?

Alex
  • 655
  • 1
  • 8
  • 16