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

SqlServerMathTranslator exception #26878

Closed
jsquire opened this issue Dec 2, 2021 · 5 comments
Closed

SqlServerMathTranslator exception #26878

jsquire opened this issue Dec 2, 2021 · 5 comments

Comments

@jsquire
Copy link
Member

jsquire commented Dec 2, 2021

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #25631.

Please be aware that @seble-nigussie is the author of the original issue and include them for any questions or replies.

Details

Library name and version

'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerMathTranslator' threw an exception. Could not find method 'Round' on type 'System.Math'

Describe the bug

Hello,

I'm getting the following exception thrown after updating to net6.0. The thing is it doesnt throw the exception locally and works fine, but in azure app service it throws. I am using the same data both locally and for dev. So, the problem couldnt be caused by the data. Its throwing this when reading from database. All my ef packages are updated to 6.0. Please help I couldnt figure out what this could be related to.

The type initializer for 'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerMathTranslator' threw an exception. Could not find method 'Round' on type 'System.Math'

Expected behavior

Should work on azure app service, like its working locally.

Actual behavior

Fails on azure app service

Reproduction Steps

I dont have one. Since its working locally.

Environment

No response

@ajcvickers
Copy link
Member

@seble-nigussie Please post your full .csproj file so that we can investigate.

@Franklin89
Copy link

I was running into the same issue on AKS. We are deploying self-contained applications with the PublishTrimmed flag set to true. Removing this flag from the dotnet publish command saved the day. Now the application is running and the call works.

RUN dotnet publish "FCResolver.csproj" -c Release -o /app/publish \
  --runtime alpine-x64 \
  --self-contained true \
  /p:PublishTrimmed=true

@ajcvickers
Copy link
Member

Tracked by #26288.

@project-one-7
Copy link

However, there is a risk that the build-time analysis of the application can cause failures at run time, due to not being able to reliably analyze various problematic code patterns (largely centered on reflection use). To mitigate these problems, warnings are produced whenever the trimmer cannot fully analyze a code pattern. For information on what the trim warnings mean and how to resolve them, see Introduction to trim warnings.
https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained

@roji
Copy link
Member

roji commented Jan 26, 2022

@project-one-7 yeah, we're well aware of that - I've been doing work on introducing the appropriate trimming annotations to the EF code base, to make things work as best as possible. Because of the way EF works, it's most likely going to be impossible to make all EF applications trimming-friendly, but it'll be possible to make the majority of them (using standard patterns) trimming-friendly. I'll update in #21894.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

5 participants