Activities of "jlavallet"

  • ABP Framework version: v 5.3.5
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:

NOTE: SQL query omitted because Cloudflare thinks I am doing SQL injection and keeps blocking my post!

2023-01-30 13:33:20.755 -06:00 [ERR] Failed executing DbCommand (30,014ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__id_0='?' (DbType = Guid)], CommandType='"Text"', CommandTimeout='30']
*[Omitted SQL was querying the SaasTenants table]*
2023-01-30 13:33:20.781 -06:00 [ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Saas.EntityFrameworkCore.SaasDbContext'.
Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
ClientConnectionId:76fa3bd3-3eac-4581-93ee-466bddd36e60
Error Number:-2,State:0,Class:11
Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`3.FindAsync(TKey id, Boolean includeDetails, CancellationToken cancellationToken)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
ClientConnectionId:76fa3bd3-3eac-4581-93ee-466bddd36e60
Error Number:-2,State:0,Class:11
2023-01-30 13:33:20.784 -06:00 [ERR] Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
   at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`3.FindAsync(TKey id, Boolean includeDetails, CancellationToken cancellationToken)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Saas.Tenants.TenantStore.GetCacheItemAsync(Nullable`1 id, String name)
   at Volo.Saas.Tenants.TenantStore.FindAsync(Guid id)
   at BlueSpot.Data.BlueSpotTenantDatabaseMigrationHandler.MigrateAndSeedForTenantAsync(Guid tenantId, String adminEmail, String adminPassword) in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.Domain\Data\BlueSpotTenantDatabaseMigrationHandler.cs:line 107
ClientConnectionId:76fa3bd3-3eac-4581-93ee-466bddd36e60
Error Number:-2,State:0,Class:11
2023-01-30 13:33:20.788 -06:00 [ERR] ---------- Exception Data ----------
HelpLink.ProdName = Microsoft SQL Server
HelpLink.ProdVer = 15.00.2095
HelpLink.EvtSrc = MSSQLServer
HelpLink.EvtID = -2
HelpLink.BaseHelpUrl = https://go.microsoft.com/fwlink
HelpLink.LinkId = 20476
  • Steps to reproduce the issue:"

I am getting the above exception when I attempt to create a tenant. From the UI perspective, the tenant is created successfully - no error messages and the new tenant appears in the list - but the tenant admin account is not created. Strangely, this works just fine on my development machine.

Given that the problem seems to be a command timeout, I have tried setting the command timeout to something like 5 minutes using the connection string:

{
 "ConnectionStrings": {
   "Default": "Server=SQL-SERVER-VM;Initial Catalog=BlueSpot;Uid=BlueSpotUser;Pwd=######;Command Timeout=300"
 },
 ...
}

That does increase the command timeout - the log error message shows a command timeout of '300' instead of '30' - but the result is the same, albeit very delayed.

2023-01-30 14:56:08.000 -06:00 [ERR] Failed executing DbCommand (300,037ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__id_0='?' (DbType = Guid)], CommandType='"Text"', CommandTimeout='300']

During this long delay I tried to query the [SaasTenants] table. The query did not complete until the original request timed out.

That was strange. I thought maybe I needed to configure MARS. So I gave that a try:

{
  "ConnectionStrings": {
    "Default": "Server=SQL-SERVER-NDR;Initial Catalog=BlueSpot.Dev;Uid=BlueSpotUser;Pwd=#BS#bs#;Command Timeout=300;MultipleActiveResultSets=True"
  },
  ...
}

Same result. No difference. What could be happening? Why does it work when I run locally?

FYI - I do have some tenant data seeding code.

Here is my SaasDataSeedContributor:

namespace BlueSpot.Saas;

public class SaasDataSeedContributor : IDataSeedContributor, ITransientDependency
{
  private readonly ICurrentTenant _currentTenant;
  private readonly IEditionDataSeeder _editionDataSeeder;
  private readonly IOrganizationUnitDataSeeder _ouDataSeeder;
  private readonly ITenantDataSeeder _tenantDataSeeder;

  public SaasDataSeedContributor(
    IEditionDataSeeder editionDataSeeder,
    IOrganizationUnitDataSeeder ouDataSeeder,
    ITenantDataSeeder tenantDataSeeder,
    ICurrentTenant currentTenant)
  {
    _editionDataSeeder = editionDataSeeder;
    _ouDataSeeder = ouDataSeeder;
    _tenantDataSeeder = tenantDataSeeder;
    _currentTenant = currentTenant;
  }

  [UnitOfWork]
  public virtual async Task SeedAsync(DataSeedContext context)
  {
    using (_currentTenant.Change(context?.TenantId))
    {
      await _editionDataSeeder.CreateStandardEditionsAsync();
      await _ouDataSeeder.CreateOrganizationUnitsAsync();
      await _tenantDataSeeder.CreateTenantAsync();
    }
  }
}

And here is my ITenantDataSeeder implementation:

namespace BlueSpot.Saas;

public class TenantDataSeeder : ITenantDataSeeder, ITransientDependency
{
  private readonly ICurrentTenant _currentTenant;
  private readonly ILocalityDataSeeder _localityDataSeeder;
  private readonly ILogger&lt;TenantDataSeeder&gt; _logger;
  private readonly IPhotoDataSeeder _photoDataSeeder;
  private readonly IRejectionReasonDataSeeder _reasonDataSeeder;

  private readonly IRoleDataSeeder _roleDataSeeder;
  private readonly IStateDataSeeder _stateDataSeeder;
  private readonly IViolationStatusDataSeeder _statusDataSeeder;
  private readonly IUserDataSeeder _userDataSeeder;
  private readonly IViolationDataSeeder _violationDataSeeder;

  public TenantDataSeeder(
    IStateDataSeeder stateDataSeeder,
    IRejectionReasonDataSeeder reasonDataSeeder,
    IViolationStatusDataSeeder statusDataSeeder,
    IRoleDataSeeder roleDataSeeder,
    IUserDataSeeder userDataSeeder,
    IPhotoDataSeeder photoDataSeeder,
    IViolationDataSeeder violationDataSeeder,
    ILocalityDataSeeder localityDataSeeder,
    ICurrentTenant currentTenant,
    ILogger&lt;TenantDataSeeder&gt; logger)
  {
    _stateDataSeeder = stateDataSeeder;
    _reasonDataSeeder = reasonDataSeeder;
    _statusDataSeeder = statusDataSeeder;
    _roleDataSeeder = roleDataSeeder;
    _userDataSeeder = userDataSeeder;
    _photoDataSeeder = photoDataSeeder;
    _violationDataSeeder = violationDataSeeder;
    _localityDataSeeder = localityDataSeeder;
    _currentTenant = currentTenant;
    _logger = logger;
  }

  public async Task CreateTenantAsync()
  {
    try
    {
      await _stateDataSeeder.CreateStatesAsync();
      await _reasonDataSeeder.CreateRejectionReasonsAsync();
      await _statusDataSeeder.CreateViolationStatusesAsync();
      await _roleDataSeeder.CreateRolesAsync();
      await _userDataSeeder.CreateUsersAsync();
      await _photoDataSeeder.CreatePhotosAsync();
      await _violationDataSeeder.CreateViolationsAsync();
      await _localityDataSeeder.CreateLocalitiesAsync();
    }
    catch (ApplicationException e)
    {
      _logger.LogException(e, LogLevel.Warning);
    }
  }
}

As you can see, there's a lot going on when a tenant is created. But I do not understand why it is timing out. Please advise. Do you see something wrong?

Just a little bit more information…

That certainly fixed that. Thank you. I suppose the important thing was to change the requiresNew parameters to false.

requiresNew (bool): Set true to ignore the surrounding unit of work and start a new UOW with the provided options. Default value is false. If it is false and there is a surrounding UOW, Begin method doesn't actually begin a new UOW, but silently participates to the existing UOW.

https://docs.abp.io/en/abp/4.3/Unit-Of-Work#begin-a-new-unit-of-work

I sent you a zip file containing my logs. There are some HTTP 500 responses in them. Any interpretation you can offer would help. Thank you.

Liming,

I figured it out. It came down to calling the wrong resource name in one of javascript files I had copied from another project. Why it manifested itself well after file was included in the project, I have no idea.

var resource = abp.localization.getResource('DonorProject');

After correcting project name to "BlueSpot" the problem went away.

Can you point me to a resource that explains how to debug the ABP Framework code?

Thanks so much!

Can I disable multi-tenancy for the Organizational Unit entity?

I know how to perform queries by using (_dataFilter.Disable<IMultiTenant>()). I created a utility class to do that:

public static class OuHelper
{
  public static async Task<IEnumerable<OrganizationUnit>> GetHostOusAsync(
    IOrganizationUnitRepository ouRepository,
    IDataFilter dataFilter)
  {
    using (dataFilter.Disable<IMultiTenant>())
    {
      return await ouRepository.GetListAsync();
    }
  }
}

but later when I want to do this:

  public async Task HandleEventAsync(EntityCreatedEventData<IdentityUser> eventData)
  {
    var ous = await OuHelper.GetHostOusAsync(_ouRepository, _dataFilter);
    var adminsOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Admins);
    var agentsOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Agents);
    var reportersOu = ous.FirstOrDefault(ou => ou.DisplayName == OrganizationUnitConsts.Reporters);

    var user = eventData.Entity;

    if (adminsOu != null)
    {
      var isInAdminOu = await _userManager.IsInOrganizationUnitAsync(user.Id, adminsOu.Id);
      var isInAdminRole = await _userManager.IsInRoleAsync(user, RoleConsts.Admin);

      if (isInAdminOu && !isInAdminRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Admin);
      }
      else if (!isInAdminOu && isInAdminRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, adminsOu.Id);
      }
    }

    if (agentsOu != null)
    {
      var isInAgentOu = await _userManager.IsInOrganizationUnitAsync(user.Id, agentsOu.Id);
      var isInAgentRole = await _userManager.IsInRoleAsync(user, RoleConsts.Agent);

      if (isInAgentOu && !isInAgentRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Agent);
      }
      else if (!isInAgentOu && isInAgentRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, agentsOu.Id);
      }
    }

    if (reportersOu != null)
    {
      var isInReporterOu = await _userManager.IsInOrganizationUnitAsync(user.Id, reportersOu.Id);
      var isInReporterRole = await _userManager.IsInRoleAsync(user, RoleConsts.Reporter);

      if (isInReporterOu && !isInReporterRole)
      {
        await _userManager.AddToRoleAsync(user, RoleConsts.Reporter);
      }
      else if (!isInReporterOu && isInReporterRole)
      {
        // THIS FAILS
        await _userManager.AddToOrganizationUnitAsync(user.Id, reportersOu.Id);
      }
    }
  }

Since it's not my entity and it's built into the Saas module, i can't remove the IMultiTenant interface. Or can I?

The desired behavior is for the Organizational Units to be application scoped and not tenant scoped.

FYI- I am using the commercial module.

[ReplaceDbContext(typeof(IIdentityProDbContext))]
[ReplaceDbContext(typeof(ISaasDbContext))]
[ConnectionStringName("Default")]
public class BlueSpotDbContext :
  BlueSpotDbContextBase<BlueSpotDbContext>,
  IIdentityProDbContext,
  ISaasDbContext
{
  public BlueSpotDbContext(DbContextOptions<BlueSpotDbContext> options)
    : base(options) { }

  public DbSet<Locality> Localities { get; set; }
  public DbSet<RejectionReason> RejectionReasons { get; set; }
  public DbSet<State> States { get; set; }
  public DbSet<Violation> Violations { get; set; }
  public DbSet<ViolationStatus> ViolationStatuses { get; set; }
  public DbSet<Photo> Photos { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityUser> Users { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityRole> Roles { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityClaimType> ClaimTypes { get; set; }

  /// <inheritdoc />
  public DbSet<OrganizationUnit> OrganizationUnits { get; set; }

  /// <inheritdoc />
  public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }

  /// <inheritdoc />
  public DbSet<IdentityLinkUser> LinkUsers { get; set; }

  /// <inheritdoc />
  public DbSet<Tenant> Tenants { get; set; }

  /// <inheritdoc />
  public DbSet<Edition> Editions { get; set; }

  /// <inheritdoc />
  public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }

  protected override void OnModelCreating(ModelBuilder builder)
  {
    builder.SetMultiTenancySide(MultiTenancySides.Both);

    base.OnModelCreating(builder);

    //...
  }

  protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
  {
    if (typeof(TEntity) == typeof(OrganizationUnit))
    {
      using (DataFilter.Disable<IMultiTenant>())
      {
        return base.CreateFilterExpression<TEntity>();
      }
    }

    return base.CreateFilterExpression<TEntity>();
  }
}

Everything compiles but when I do a Add-Migration I get the following:

PM> Add-Migration IdentityAndSassDbContext -Context BlueSpotDbContext
Multiple startup projects set.
Using project 'src\BlueSpot.EntityFrameworkCore' as the startup project.
Build started...
Build succeeded.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.get_DataFilter() in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 51
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContext.CreateFilterExpression[TEntity]() in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContext.cs:line 176
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.ConfigureGlobalFilters[TEntity](ModelBuilder modelBuilder, IMutableEntityType mutableEntityType) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 604
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.ConfigureBaseProperties[TEntity](ModelBuilder modelBuilder, IMutableEntityType mutableEntityType) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 596
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Volo.Abp.EntityFrameworkCore.AbpDbContext`1.OnModelCreating(ModelBuilder modelBuilder) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.EntityFrameworkCore\Volo\Abp\EntityFrameworkCore\AbpDbContext.cs:line 105
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContextBase`1.OnModelCreating(ModelBuilder builder) in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContextBase.cs:line 35
   at BlueSpot.EntityFrameworkCore.BlueSpotDbContext.OnModelCreating(ModelBuilder builder) in D:\Century\Internal\BlueSpot\BlueSpot\src\BlueSpot.EntityFrameworkCore\EntityFrameworkCore\BlueSpotDbContext.cs:line 78
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, ModelDependencies modelDependencies)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
   at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__8_4(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance()
   at Microsoft.EntityFrameworkCore.Infrastructure.Internal.InfrastructureExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
   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.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Exception has been thrown by the target of an invocation.

Please advise. I hope you guys are safe out there. The earthquake seems terrible.

https://centurycorporation-my.sharepoint.com/:u:/p/jlavallet/EcMPpnAcCJZJjYWscoCsSlYBUukgDLOGlP4Slu0F46YU7g?e=lepKQV

I've Included a link to the logs after incorporating that change. I'm getting a foreign key constraint violation with the database. Please see the BlueSpot.HttpApi.Host\logs.txt file. It appears to have some kind of conflict with the CMS module.

Again, everything compiles fine. The migration was created just fine - although I didn't need it because there weren't any schema changes. The DbMigrator seemed to run fine - although I did see some red output lines when it ran, there was nothing in its log. The problem manifested itself when I tried to create a new tenant.

Related With this problem, I'm also having a problem when I try to programmatically create a Tenet. I am trying to do this using the _tenantManager.CreateAsync(string name, Guid? editionId) method:

      if (!_currentTenant.IsAvailable &&
          await _tenantRepository.FindByNameAsync(TenantConsts.ShelbyCoTenantName) == null)
      {
        var editions = await _editionRepository.GetListAsync();
        var edition = editions.FirstOrDefault(edition => edition.DisplayName == "Standard");
        var tenant = await _tenantManager.CreateAsync(TenantConsts.ShelbyCoTenantName, edition.Id);

        //await _tenantRepository.UpdateAsync(tenant);
      }

      else if (_currentTenant.IsAvailable && _currentTenant.Name == TenantConsts.ShelbyCoTenantName)
      {
        var tenant = await _tenantRepository.FindByIdAsync(_currentTenant.Id.Value);
        var alState = await _stateRepository.GetAsync(state => state.Code == "AL");

        tenant.ExtraProperties[TenantConsts.AddressLine1PropertyName] = "P.O. Box 1095";
        tenant.ExtraProperties[TenantConsts.CityPropertyName] = "Columbiana";
        tenant.ExtraProperties[TenantConsts.StateIdPropertyName] = alState.Id;
        tenant.ExtraProperties[TenantConsts.ZipCodePropertyName] = "35051";

        await _tenantRepository.UpdateAsync(tenant);
      }

The method completes but no Tenant is created. What's up with that? I am using Extra Properties for my Tenant and there is no way to pass in those properties using this method. The else if block above was one attempt I had made to update those properties after the tenant was created but that did not help. I also tried the following code to try and initialize the extra properties:

public class TenantCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<Tenant>>, ITransientDependency
{
  private readonly ICurrentTenant _currentTenant;
  private readonly IStateRepository _stateRepository;
  private readonly ITenantRepository _tenantRepository;
  private readonly IUserDataSeeder _userDataSeeder;

  public TenantCreatedEventHandler(ITenantRepository tenantRepository, IStateRepository stateRepository,
    ICurrentTenant currentTenant, IUserDataSeeder userDataSeeder)
  {
    _tenantRepository = tenantRepository;
    _stateRepository = stateRepository;
    _currentTenant = currentTenant;
    _userDataSeeder = userDataSeeder;
  }

  /// <inheritdoc />
  public async Task HandleEventAsync(EntityCreatedEventData<Tenant> eventData)
  {
    try
    {
      var tenant = eventData.Entity;
      if (tenant.Name == TenantConsts.ShelbyCoTenantName)
      {
        using (_currentTenant.Change(tenant.Id))
        {
          var alState = await _stateRepository.GetAsync(state => state.Code == "AL");

          tenant.ExtraProperties[TenantConsts.AddressLine1PropertyName] = "P.O. Box 1095";
          tenant.ExtraProperties[TenantConsts.CityPropertyName] = "Columbiana";
          tenant.ExtraProperties[TenantConsts.StateIdPropertyName] = alState.Id;
          tenant.ExtraProperties[TenantConsts.ZipCodePropertyName] = "35051";

          await _tenantRepository.UpdateAsync(tenant);

          await _userDataSeeder.CreateUsersAsync();
        }
      }
    }
    catch (Exception e)
    {
      Console.WriteLine(e);
      throw;
    }
  }
}

That code was not called after the programmatic creation attempt.

One more thing As I am using the commercial version of the Identity and Sass modules, I would like access to the following .cshtml files:

Pages\Tenets\CreateModal.cshtml
Pages\Tenets\EditModal.cshtml

I'm not sure about the namespace/Intermediate folders. I need to change some controls and styling. How do I get access to that? I tried getting the framework's TenantManagement files but I quickly determined that that was the framework and not the commercial module pages that I need.

Thankful you guys are okay!

Is it possible for me to get the cshtml files without the models, etc.?

顯示 43 個紀錄的 31 到 40 個.
Made with ❤️ on ABP v8.2.0-preview Updated on 3月 25, 2024, 15:11