dotnet / dotnet/efcore

EFCore (7.0) in MAUI (.NET 7) - first query in Release mode always throws error (Android)

Open
#29,589 1 comment 1 reaction 0 assignees View on GitHub
area-external customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### Description

When using EFCore and building the app in Release mode, the first query that returns any result, will throw an exception "Could not load file or assembly 'System.Runtime.Caching'... or one of its dependencies"
Every subsequent query works fine, and building the app in Debug mode works fine as well.

https://user-images.githubusercontent.com/36468942/202162298-bec27882-09be-4095-9a2b-307479421c94.mp4

### Steps to Reproduce

1. Create MAUI app, add the EFCore packages, try to read a row from a SQL database in Release mode

or take the repo, modify it so it reads any data from any sql database (as far as I am aware, you have to embed the .cer file that is used on the sql server, or install it onto the testing device)

Press the bottom button once for error, twice for success

### Link to public reproduction project repository

https://github.com/jovanmhn/EFCoreTest

### Version with bug

7.0 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

Android

### Affected platform versions

Android 12 API 31

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.