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

TypeInitialization_Type, Microsoft.EntityFrameworkCore.Query.EvaluatableExpressionFilter: Could not find property 'Now' on type 'System.DateTimeOffset' when trimmed #27936

Closed
1618employment opened this issue May 3, 2022 · 3 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported

Comments

@1618employment
Copy link

FWIW EF Core 6.0 definitely doesn't "support" trimming; we're doing some specific changes to unblock general use (e.g. #27910, #27098), but we're aware that specific use-cases would still fail after those. We're planning to address trimming more systematically in 7.0.

Specifically for DateTimeOffset.Now, I didn't run into that when using SQL Server or SQLite with minimal basic patterns, @1618employment can you please open an issue on https://github.com/dotnet/efcore with a minimal repro and we'll look into addressing that?

From or see issue dotnet/linker#2768

Include provider and version information

EF Core version: 6.0.4
Database provider: Microsoft.EntityFrameworkCore.InMemory
Target framework: (e.g. .NET 6.0)
Operating system: All (Blazor browser-wasm)
IDE: Visual Studio 2022 17.1.6

@roji
Copy link
Member

roji commented May 3, 2022

@1618employment I could not reproduce an issue here with InMemory - please submit a minimal, runnable code sample that reproduces the error.

Stepping back, can you provide more context on why you're using InMemory in a trimmed application? InMemory definitely should not be used in production applications, and it seems odd to be trimming test projects (note that even for testing, use of InMemory is discouraged).

@1618employment
Copy link
Author

...yeah I knew that was coming...because I originally used Sqlite as the provider when I was writing for mobile/desktop. But I switched to blazer WASM and browsers don't support Sqlite, so I swapped Sqlite out for InMemory to avoid ditching or rewriting all my EF code. I persisted my data structures in IndexDB and then load them into EF InMemory...does EF support IndexDB as a provider yet? InMemory has worked fine until "auto trimming"...why is it discouraged? Sorry, I guess I'm not a big rule follower!

<PublishTrimmed>false</PublishTrimmed> resolved my issue, you can close this if you want, thank you!

@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label May 6, 2022
@roji
Copy link
Member

roji commented May 7, 2022

@1618employment I'm not aware an IndexDB provider. But in general, if what you want is to load data into memory and query it via LINQ operators, I'm not sure why you'd use EF Core - just use general .NET collections (List, Collection) and use regular LINQ aganist them.

InMemory was not designed for production - it's slow, lacks various features, etc..

@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
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants