IdentityServer icon indicating copy to clipboard operation
IdentityServer copied to clipboard

IPersistedGrantDbContext.SaveChangesAsync(CancellationToken cancellationToken = default) not implemented by AspnetCore .NET 6-rc.2.21480.5

Open e-gauthier opened this issue 5 years ago • 3 comments

Which version of Duende IdentityServer are you using? 6.0.0-preview.2

Which version of .NET are you using? .NET 6.0.0-rc.2.21480.5

Describe the bug We are currently migrating our application from .NET 5 to .NET 6.0.0-rc.2.21480.5.
All reference to IdentityServer4 have been updated with Duende.IdentityServer.

When attempting to add a new migration to resolve new dependencies, the error below occurs. (See Data section)

To Reproduce

  1. Create a database using code first with IdentityServer4 and .NET 5
  2. Update the database
  3. Update the project to .NET 6.0.0-rc.2.21480.5
  4. Update all references of IdentityServer4 to Duende.IdentityServer
  5. Execute add-migration to generate a new snapshot.

Expected behavior

The new migration has been created without error.

Log output/exception with stacktrace


An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Method not found: 'System.Threading.Tasks.Task`1<Int32> Duende.IdentityServer.EntityFramework.Interfaces.IPersistedGrantDbContext.SaveChangesAsync()'.
System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Int32> Duende.IdentityServer.EntityFramework.Interfaces.IPersistedGrantDbContext.SaveChangesAsync()'.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c.<FindContextTypes>b__21_5(TypeInfo t)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
at System.Linq.Enumerable.DistinctIterator`1.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextTypes()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextType(String name)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Method not found: 'System.Threading.Tasks.Task`1<Int32> Duende.IdentityServer.EntityFramework.Interfaces.IPersistedGrantDbContext.SaveChangesAsync()'.

Additional context

Latest implementation of IPersistedGrantDbContext by AspNetCore IdentityServer Task IPersistedGrantDbContext.SaveChangesAsync() => base.SaveChangesAsync(); aspnetcore/ApiAuthorizationDbContext.cs at v6.0.0-rc.2.21480.10 · dotnet/aspnetcore (github.com)

Duende.IdentityServer.EntityFramework.Interfaces.IPersistedGrantDbContext

Version 6.0.0-Preview.1 => Task SaveChangesAsync();

Version 6.0.0-Preview.2 => Task SaveChangesAsync(CancellationToken cancellationToken = default);

e-gauthier avatar Oct 18 '21 21:10 e-gauthier

I just merged a PR with a fix. Can you re-test against our dev build? https://docs.duendesoftware.com/identityserver/v5/overview/packaging/#dev-builds

brockallen avatar Oct 20 '21 18:10 brockallen

I was running into the same issue and the dev build 6.0.0-preview.2.1 has fixed it

Thank you folks

dnlruzzo avatar Oct 21 '21 14:10 dnlruzzo

I just merged a PR with a fix. Can you re-test against our dev build? https://docs.duendesoftware.com/identityserver/v5/overview/packaging/#dev-builds

It work! Thx you.

e-gauthier avatar Oct 21 '21 19:10 e-gauthier