Base solution for your next web application
Open Closed

EF Core Interceptors #10982


User avatar
0
zyrel.sermon created

Hi,

Is there any tutorial or documentation on how to implement interception logic in EF Core? Is there a retry mechanism in anz for creating connections in the database? we are using v8.2.0.0

Thanks


20 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    Could you share what would you like to achive by interception ? We can offer you a solution accordingly.

    Thanks

  • User Avatar
    0
    zyrel.sermon created

    We are having peak connection issues on our azure servers, based on the recommendation of the azure engineer, they recommend to implement a interception login in EF core if there is none, that's why we are asking if there is a documentation of interception in anz? Or is it already implemented in anz version 8.2.0.0? And is there a retry mechanism in anz for creating connections in the database? Please advise.

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    AspNet Zero doesn't have EF Core interceptors. I couldn't understand how this will help to solve the problem you are having. Before implementing EF Core interceptors, could you try the steps below;

    1. Update your ABP pacakges to 6.6.2 or to latest 7.x version.
    2. Implement changes in https://github.com/aspnetzero/aspnet-zero-core/pull/4234

    Thanks,

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    thanks for the response, we will check this. How about the retry mechanism if there is failure in creating connection in the database is it already implemented in anz?

    Thanks,

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Currently, AspNet Zero doesn't support the retry mechanism. You can follow https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3221 for that feature.

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    We will try to implement first the changes on jwt validation and we'll update you once soon.

    Thanks

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    Code changes are applied and abp packages are already updated but we've encountered some errors when building the project. Attached is the screenshot of the error, please advise, thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Please use only Abp.AspNetCore.SignalR if your project is an ASP.NET Core (.NET Core) project. If it is an ASP.NET MVC 5.x app (.NET 4.6.1), use only Abp.Web.SignalR package.

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    We already remove the Abp.Web.SignalR since our project is an ASP.NET Core (.NET Core) but we still encountered some issues Please advise. Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    Could you open NuGet Package Manager and see if you have any packages listed under Consolidate tab ? I think you have some packages with different versions in your project.

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    i've already updated the version of the packages but when building the project i've encounter this issue please advise, Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please inject below item to your Exception class and provide it to the constructor as the 3rd parameter

    public class SprintTekExceptionFilter: AbpExceptionFilter{
    
        public SprintTekExceptionFilter(IErrorInfoBuilder errorInfoBuilder,
                IAbpAspNetCoreConfiguration configuration,
                IAbpWebCommonModuleConfiguration abpWebCommonModuleConfiguration): base(errorInfoBuilder, configuration, abpWebCommonModuleConfiguration) {
        
        }
    
    }
    
  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    tried injecting the item based on what you've suggested but after building the project here's what i've got tried adding migration also, its possible that it's just missing a migration but here's the error when adding migration Am i missing something?

    Please advise, Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please add a new migration to your app using "dotnet ef migrations add MIGRATION_NAME" and then update your local database using "dotnet ef database update" and try again.

    Thanks,

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas,

    I'm running the command on the package manager console of visual studio, as you can see the the build started and succeeded but encounters and error

    PM> add-migration
    cmdlet Add-Migration at command pipeline position 1
    Supply values for the following parameters:
    Name: test
    Build started...
    Build succeeded.
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
     ---> System.TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer' from assembly 'Microsoft.EntityFrameworkCore, Version=6.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(IOperationReportHandler reportHandler, IDictionary args)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
       at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
       at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Activator.CreateInstance(Type type, Object[] args)
       at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language)
       at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
       at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsAddCommand.Execute()
       at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
       at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
       at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
    Exception has been thrown by the target of an invocation.
    

    it is possible that there are packages affected internally when we updated the ff:?

    Update your ABP pacakges to 6.6.2 or to latest 7.x version.
    Implement changes in https://github.com/aspnetzero/aspnet-zero-core/pull/4234
    

    Please advise, thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    Is it possible to share your project via email with us ? We can fix these problems for you faster in that way. If that is possible, please share your project with [email protected].

    Thanks,

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    Project file sent to [email protected]

    Kindly check on your end, Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    I have replied to your email. We can continue via email.

  • User Avatar
    0
    zyrel.sermon created

    Hi @ismcagdas

    I've already sent the updated project file via email. Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    Thanks, replied to your email.