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

Activities of "mightyit"

@alper the issue persists

@ismcagdas I have done that. The error persists.

Guys, I am having serious issues with data access on backgroundjobs, both using EF and Dapper. See also https://support.aspnetzero.com/QA/Questions/7219

Can we please escalate this to get to a resolution? This is putting my project at serious risk. Please contact me via email to resolve it directly.

System.Data.SqlClient.SqlException HResult=0x80131904 Message=Invalid object name 'PersonRecord'. Source=Core .Net SqlClient Data Provider StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in C:\projects\dapper\Dapper\SqlMapper.cs:line 1064 at Dapper.SqlMapper.<QueryImpl>d__1381.MoveNext() in C:\projects\dapper\Dapper\SqlMapper.cs:line 1081 at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable1 commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:line 723 at DapperExtensions.DapperImplementor.GetList[T](DbConnection connection, IClassMapper classMap, IPredicate predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at DapperExtensions.DapperImplementor.GetList[T](DbConnection connection, Object predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at DapperExtensions.DapperExtensions.GetList[T](DbConnection connection, Object predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at Abp.Dapper.Repositories.DapperRepositoryBase2.GetAll() at Castle.Proxies.Invocations.DapperRepositoryBase2_GetAll.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.DapperEfRepositoryBase3Proxy.GetAll() at MyModule.SearchServices.Infrastructure.UnscConsolidatedSanctionList.Infrastructure.Persons.PersonMonitoringBatch.PersonMonitoringBatchSearchJob.ExecuteJob(PersonMonitoringBatchSearhJobArgs args) in D:\Projects\MySystem\Modules\MyModule\MyModule.SearchServices.Infrastructure.UnscConsolidatedSanctionList\Infrastructure\Persons\PersonMonitoringBatch\PersonMonitoringBatchSearchJob.cs:line 91 at MyModule.SearchServices.Infrastructure.UnscConsolidatedSanctionList.Core.BatchSearchJobBase`1.Execute(TBatchSearhJobArgs args) in D:\Projects\MySystem\Modules\MyModule\MyModule.SearchServices.Infrastructure.UnscConsolidatedSanctionList\Core\BatchSearchJobBase.cs:line 20

Hi @ismcagdas

Yes, I have. I am still getting the same issue though.

@ismcagdas Any ideas?

@ismcagdas In general I would recommend that you split the default generated / main solution up into smaller modules. The main solution tends to grow quickly in terms of complexity and size, and upgrades become increasingly more difficult and unmanageable. Smaller modules means you could also do your releases for particular modules, meaning smaller, more manageable merges.

Good candidates for seperate modules:

  • Identity & Authorization
  • Payments, accounts, subscriptions and editions
  • Auditing and Logging
  • Localization and Internationalization
  • Main

@ryancyq @ismcagdas were you able to recreate the issue?

Your use case is not supported out-of-the-box. The way to go is to program tier 2 and 3 as two specialised types of tenants, and setup permissions / roles accordingly. You can also explicitly code in behaviour for things like impersonation if you need it.

If you really need seperate databases per branch, then why not just treat tiers 2 & 3 as seperate tenants?

Let's say we have a table called "MyEntities" in SQL Server with the corresponding IEntity class "MyEntity"; The class "MyEntity" is decorated with the [TableName("MyEntities")] attribute.

When using IDapperRepository<MyEntity> to query the database, it unfortunately resolves to the singular form for the table name, in stead of the TableName attribute specified.

Is there any way to correct this behaviour?

[Table("PersonRecords")]
public class PersonRecord : FullAuditedEntity<Guid>, IMayHaveTenant
{
          //More attributes
}
// Meanwhile, in a client class somewhere....
public class Consumer 
{

    private readonly IDapperRepository<PersonRecord, Guid> _personRecordDapperRepository;

    public Consumer(
        IDapperRepository<PersonRecord, Guid> personRecordDapperRepository)
    {
        _personRecordDapperRepository = personRecordDapperRepository;
    }

    public void DoSomething()
    {
            _personRecordDapperRepository.GetAll(); // <== Generates exception
    }
}

Here is the exception:

System.Data.SqlClient.SqlException HResult=0x80131904 Message=Invalid object name 'PersonRecord'. Source=Core .Net SqlClient Data Provider StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in C:\projects\dapper\Dapper\SqlMapper.cs:line 1064 at Dapper.SqlMapper.<QueryImpl>d__1381.MoveNext() in C:\projects\dapper\Dapper\SqlMapper.cs:line 1081 at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable1 commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:line 723 at DapperExtensions.DapperImplementor.GetList[T](DbConnection connection, IClassMapper classMap, IPredicate predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at DapperExtensions.DapperImplementor.GetList[T](DbConnection connection, Object predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at DapperExtensions.DapperExtensions.GetList[T](DbConnection connection, Object predicate, IList1 sort, DbTransaction transaction, Nullable1 commandTimeout, Boolean buffered) at Abp.Dapper.Repositories.DapperRepositoryBase2.GetAll() at Castle.Proxies.Invocations.DapperRepositoryBase2_GetAll.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.DapperEfRepositoryBase3Proxy.GetAll()

Here it is, but, as I mentioned, there really is no other useful information:

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) at MyNameSpace.TroubleshootingBackgroundJob.Execute(TroubleshootingBackgroundJobArgs args) in REDACTED\TroubleshootingBackgroundJob.cs:line 17

Showing 31 to 40 of 66 entries