System.MissingMethodException: Method not found: System.String Microsoft.EntityFrameworkCore.Metadata.IPropertyBase.get_Name()

Rashmi
Rashmi
Member
820 Points
17 Posts

I'm migrating .net 5.0 to .net7.0. Getting following error:

System.MissingMethodException: Method not found: 'System.String Microsoft.EntityFrameworkCore.Metadata.IPropertyBase.get_Name()'.
   at AspNetCore.EntityFrameworkCore.AuditTrail.AuditableContext.OnBeforeSaveChanges(String userId)
   at AspNetCore.EntityFrameworkCore.AuditTrail.AuditableContext.SaveChangesAsync(String userId)
   at "Infrastructure.DbContexts.ApplicationDbContext.SaveChangesAsync(CancellationToken cancellationToken) in "Infrastructure\DbContexts\ApplicationDbContext.cs:line 54
   at "Infrastructure.Repositories.UnitOfWork.Commit(CancellationToken cancellationToken) in "Infrastructure\Repositories\UnitOfWork.cs:line 24
   at "Application.Features.MyBrands.Commands.Create.CreateMyBrandCommandHandler.Handle(CreateMyBrandCommand request, CancellationToken cancellationToken) in "Application\Features\MyBrands\Commands\Create\CreateMyBrandCommand.cs:line 36
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at "Web.Areas.Catalog.Controllers.MyBrandController.OnPostCreateOrEdit(Int32 id, MyBrandViewModel MyBrand) in "Web\Areas\Catalog\Controllers\MyMyBrandController.cs:line 63
   at lambda_method588(Closure, Object)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at AspNetCore.ToastNotification.Middlewares.NotyfMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

 

 

Views: 1057
Total Answered: 1
Total Marked As Answer: 1
Posted On: 22-May-2023 02:40

Share:   fb twitter linkedin
Seems, there is problem in AspNetCore.EntityFrameworkCore.AuditTrail
 - Rahul Maurya  22-May-2023 02:59
thanks Rahul. Looking on the same.
 - Rashmi  22-May-2023 03:07
Answers
Rashmi
Rashmi
Member
820 Points
17 Posts
         

I think, there is bug in audit package with .net 7.0.

Found here same issue:
https://github.com/aspnetcorehero/EntityFrameworkCore.AuditTrail/issues/2

 

I'm not going to fix it. I just commented audit code block on user logged in:

Posted On: 22-May-2023 03:13
Great!
 - Rahul Maurya  22-May-2023 03:15
 Log In to Chat