You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[.NET 6] Migrate API - Could not find method 'AddYears' on type 'System.DateOnly' #26860
If users were to use the trimming option in .NET 6, one might face this exception if they used Migrate() or MigrateAsync() API.
Could not find method 'AddYears' on type 'System.DateOnly' at System.SharedTypeExtensions.GetRequiredRuntimeMethod(Type type, String name, Type[] parameters)
For now, it can be workaround with adding a line of code (preferably in main class) or using rd.xml
/// <summary>/// FIXME: This is required for EF Core 6.0 as it is not compatible with trimming./// </summary>[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]privatestaticType_keepDateOnly=typeof(DateOnly);
Include provider and version information
EF Core version: 6.0.0
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 6.0
Operating system: Windows 10
IDE: Visual Studio 2022
@jianmingyong I've started to look into this, could you please post a full stack trace of the exception you got with AddYears? I'm specifically interested since that exception was triggered from Migrate.
Activity
roji commentedon Dec 1, 2021
Duplicate of #26288
roji commentedon Dec 1, 2021
#26288 tracks making all reflection-based method lookup compatible with trimming (rather than having an issue for each method).
roji commentedon Jan 3, 2022
@jianmingyong I've started to look into this, could you please post a full stack trace of the exception you got with AddYears? I'm specifically interested since that exception was triggered from Migrate.