Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "mightyit"

@ryancyq It is the only line omitted from the Stacktrace as I actually copied it from production code. I indicated the originating line in the code snippet with the comment // <== Generates the exception

The generic repository for an entity with the [Audited] decoration will cause an exception due to DbContext being disposed prematurely. I am using Hangfire.

 [Audited]
    public class MyAuditedEntity: FullAuditedEntity<Guid>
    {
        public virtual string Name { get; set; }
        public virtual string Description { get; set; }
    }
public class TroubleshootingBackgroundJob : BackgroundJob<TroubleshootingBackgroundJobArgs>, TransientDependency
{
    private readonly IRepository<MyAuditedEntity, Guid> _repository;

    public TroubleshootingBackgroundJob(IRepository<MyAuditedEntity, Guid> repository)
    {
        _repository = repository;
    }

    [UnitOfWork]
    public override void Execute(TroubleshootingBackgroundJobArgs args)
    {
        repository.GetAll().ToList(); // <== Generates the exception
    }
}

Exception details:

System.ObjectDisposedException HResult=0x80131622 Message=Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. ObjectDisposed_ObjectName_Name Source=Microsoft.EntityFrameworkCore StackTrace: at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() at Microsoft.EntityFrameworkCore.DbContext.get_Model() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityType() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityQueryable() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.System.Linq.IQueryable.get_Provider() at System.Linq.Queryable.Where[TSource](IQueryable1 source, Expression`1 predicate)

Am I missing something or is this a bug?

UPDATE It seems the problem is with all types of FullAuditedEntity, not the [Audited] decoration...

As far as I can see the EFPlus library only offers extensions for bulk update and delete, not insert. Is this correct or am I mistaken?

I am working on a feature which deals with bulk dataprocessing and of which the performance and scalability aspects is critical.

During the execution of the operation I have to insert thousands of records to the database via EfCore. I am hoping to do this with a single trip to the database through a BulkInsert extension method on IRepository<T>.

I have read the following thread which creates the impression that this functionality has been incorporated into the Abp framework, but I am having trouble surfacing it https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3476

I have also noticed that there is a Nuget package Abp.EntityFrameworkCore.BulkExtensions, but this was last updated in 2017.

What is currently the recommended avenues to perform bulk database operations in AspNetZero / EfCore?

Hi @ismcagdas

I have implemented the temporary workaround but have came to the same conclusion as your second suggestion - that a shared library for authentication and authorization should be created. Perhaps something to consider for future versions of the boilerplate solution (if I may suggest)?

I'm not mistaken. I know the generic repository pattern. I'm talking about clean coding (SOLID) practices.

Thanks for the feedback.

This wil work as a temporary quickfix, but is wrong insofar as clean coding principles.

  1. Creates an explicit dependency on a concrete class
  2. Tightly couples my module to my base solution (The User class is generated as part of your base solution and inherits from AbpUserBase).

I am trying to do custom / direct registration as per the official dependency injection documentation, but without success.

Hi

I am getting the following error during run-time when trying to invoke a method on ***AppService, which is contained in a separate, well-contained module that is separate from my generated solution modules.

The module consists of several sub-modules, with proper dependencies set up between them

I have also done the following in terms of module dependencies:

  • Added a module dependency from my module core to AbpZeroCommonModule
  • Added the required module dependencies from my base solution Web.Core solution to the custom modules. (All app services from the module runs successfully, except this specific one)

Can't create component '***AppService' as it has dependencies to be satisfied.

'***AppService' is waiting for the following dependencies:

  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.AbpUserBase, Abp.Zero.Common, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.

Castle.MicroKernel.Handlers.HandlerException: Can't create component '***AppService' as it has dependencies to be satisfied.

'***AppService' is waiting for the following dependencies:

  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.AbpUserBase, Abp.Zero.Common, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.

Here is the redacted code for the affected applicationservice:

Please help - what am I missing here?

Oh fudge....

Thanks. That was pretty much the approach I was trying to avoid, as it now means that "generic" services which the AspNetZero / ABP framework provides out-of-the-box can not be used.

Also, I was trying to rely on DI for Azure Functions V2 - as you can see in that post it is still very unstable.

Appreciate the input!

Hi

I am currently developing some Azure functions (.Net 2.2, V2) and it's support for dependency injection is highly unstable (almost non-existant, atm). In addition, AspNetZero / ABP conventions will not apply to Azure functions.

In this scenario, I am forced to new up instances of app services, and perhaps domain services.

I would specifically like to find out how I can new up instances of Crud App Services and generic repositories?

Thanks

Showing 41 to 50 of 66 entries