Base solution for your next web application

Activities of "bulutyonetim"

Hi,

Solved the problem by changing code to this.

    public ProjectNameConnectionStringResolver(IAbpStartupConfiguration configuration,IAmbientDataContext ambientDataContext)
            : base(configuration)
        {
            _appConfiguration = AppConfigurations.Get(
                typeof(ProjectNameConnectionStringResolver).GetAssembly().GetDirectoryPathOrNull(),
                Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
            );
            _ambientDataContext = ambientDataContext;
        }

Thanks @ismcagdas

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

-What is your product version? 10.3 -What is your product type (Angular or MVC)? Angular -What is product framework type (.net framework or .net core)? .netCore

If issue related with ABP Framework

  • What is ABP Framework version? 6.3.1

Hi I have a ConnectionStringResolver like this:

` public class ProjectNameConnectionStringResolver : DefaultConnectionStringResolver { private readonly IConfigurationRoot _appConfiguration; private readonly IAmbientDataContext _ambientDataContext;

    public ProjectNameConnectionStringResolver(IAbpStartupConfiguration configuration, IHostingEnvironment hostingEnvironment, IAmbientDataContext ambientDataContext)
        : base(configuration)
    {
        _appConfiguration = AppConfigurations.Get(hostingEnvironment.ContentRootPath, hostingEnvironment.EnvironmentName);
        _ambientDataContext = ambientDataContext;
    }

    public override string GetNameOrConnectionString(ConnectionStringResolveArgs args)
    {
        if ((string)_ambientDataContext.GetData(ProjectNameConsts.DatabaseSelection) == ProjectNameConsts.SelectedDatabase.ReadDatabase)
        {
            string xx = _appConfiguration.GetConnectionString(ProjectNameConsts.ReadReplicaConnectionStringName);
            return xx;
        }

        return base.GetNameOrConnectionString(args);
    }
}

And it has been register like this in EntityFrameworkCoreModule:

            Configuration.ReplaceService(typeof(IConnectionStringResolver), () =>
            {
                IocManager.Register<IConnectionStringResolver, PuduxConnectionStringResolver>(DependencyLifeStyle.Transient);
            });

Everything works fine. but when I try to run migrator I recive following error:

2021-06-28 18:15:20 | HOST database migration started...
2021-06-28 18:15:20 | An error occured during migration of host database:
2021-06-28 18:15:20 | Castle.MicroKernel.Handlers.HandlerException: Can't create component 'ProjectName.EntityFrameworkCore.ProjectNameConnectionStringResolver' as it has dependencies to be satisfied.

'ProjectName.EntityFrameworkCore.ProjectNameConnectionStringResolver' is waiting for the following dependencies:
- Service 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' which was not registered.

   at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.TryResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency, Object& value)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext)
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, Boolean ignoreParentContext)
   at Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments)
   at Castle.Windsor.WindsorContainer.Resolve[T]()
   at Abp.Domain.Uow.UnitOfWorkManager.Begin(UnitOfWorkOptions options)
   at Abp.Domain.Uow.UnitOfWorkManager.Begin(TransactionScopeOption scope)
   at Abp.Zero.EntityFrameworkCore.AbpZeroDbMigrator`1.CreateOrMigrate(AbpTenantBase tenant, Action`1 seedAction)
   at Abp.Zero.EntityFrameworkCore.AbpZeroDbMigrator`1.CreateOrMigrateForHost(Action`1 seedAction)
   at ProjectName.Migrator.MultiTenantMigrateExecuter.Run(Boolean skipConnVerification, Boolean isDockerEnabled) in D:\Workspace\Work\XX\ProjectNameProjects\ProjectName-10.3.0\src\ProjectName.Migrator\MultiTenantMigrateExecuter.cs:line 62
2021-06-28 18:15:20 | Canceled migrations.

As I understand the problem, main project has an registered IHostingEnvironment injection but this service is not injected to Migrator.

Can you guide me how to inject this to migrator.

Thank you

Hi,

Our subscription has been expired I don't have access to that repo, So I cannot add issue there.

Thank you

Prerequisites

  • What is your product version? 10.3
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .netCore

If issue related with ABP Framework

  • What is ABP Framework version?

Hi there,

This is not a support ticket just requesting some feture on Power tool,

I am trying to use power tools for some create some multi language entitiy. It does not have this feature It will be good to have this feature.

But When I try to add manually I got some problem.

Check this entity for example:

ProfessionGroup entity does not have any other column so power tool does not let me create that.

So I have to add it with fake column then remove that fake column from codes.

Then when I need to add ProfessionGroup as foreign key to an other table it also does not let me to add because there is not any Display property.

Can you check these problems on your next release.


One more suggestion for power tool. Can we have checkbox on regenerate entity like "Save User Changes" when it is checked, On regenerating files do not delete user files just comment their inside and add new code.

Why I ask this:

Normally users generates entities then they do some changes on them (for example they changes some part on UI and etc..) then they need to add some extra columns on the entity. Now your regenrates code ovrrides users all changes and it is not good.

If you provide such a option that I wrote, user changes will not gone and user can access them trhough comments in that file.

Thank you.

IAmbientDataContext helped me to achive what I need.

Thanks @zony.

Hi,

I managed to override IConnectionStringResolver successfully and now I can change connection string dynamically but how should I know that this is a read request so I should change connection string to Read Replica database?

I found this solution in one of support tickets. It says:

You can define an attribute (for Get only) and use it the operations you want to use read-only database.

Can you show me how to add attribute to ConnectionStringResolveArgs for example when calling a get method in any repository? So, in this case I can decide based on that attribute inside my custom IConnectionStringResolver and change connection string.

Hi Zony,

Thanks for answer.

I saw first solution, but it is not good solution for my scenario because In that case I will have all tables and Dbsets and etc.. duplicated and project will turn into mess.

Can you describe second solution a bit more? Is ther any documentation for this. any code sample?

Thanks

Prerequisites

  • What is your product version? v9.0.1
  • What is your product type (Angular or MVC)? ASP.NET CORE & Angular (single solution)
  • What is product framework type (.net framework or .net core)? .NET Core 3.1

If issue related with ABP Framework

  • What is ABP Framework version? 5.10.1

Hi

We are using Amazon Relational Database Service (RDS). We have one primery database which is read/write databse. also we have one Read Replica database which is only read-only. Both database schema's are exactly same and the data is almost same but maybe with a few milsecond dely.

When we want to write any record to database we should connect to 1st database, but when we want to read we need to connect to read replica database. (also sometimes we may need to read from 1st database).

Can you guide me how to achive this via Asp.net Zero?

Thanks

Hi,

I tried these steps:

  1. Configure Web.Host\appsettings.Staging.json as you said with same value like this:

    {
      "ConnectionStrings": {
        "Default": "Server=localhost; Database=xxxDb; User=xxx; Password=xxx;"
      },
      "App": {
        "ServerRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
        "ClientRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
        "CorsOrigins": "http://test.sitename.com,http://*.test.sitename.com"
      }
    }
    
  2. Run dotnet publish --configuration Staging --output ../../Publish/SiteName /p:EnvironmentName=Staging

  3. Create IIS web site with these bindings test.sitename.com and *.test.sitename.com

  4. Copied all publish files to IIS site's physical path.

  5. Then tried to visit test.sitename.com, I get this erorr Oops! You're lost. We can not find the page you're looking for.

  6. Then tried to visit test.sitename.com/ui/login it loads api login pages. But i couldn't find a way to load ui.

  7. I Change config like this:

    {
      "ConnectionStrings": {
        "Default": "Server=localhost; Database=xxxDb; User=xxx; Password=xxx;"
      },
      "App": {
        "ServerRootAddress": "http://{TENANCY_NAME}.api.test.sitename.com/",
        "ClientRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
        "CorsOrigins": "http://test.sitename.com,http://*.test.sitename.com"
      }
    }
    

but result was same.

note: I can get things work with two IIS site one for UI and the other for api. But I think it shoud also work under one site.

Hi @ismcagdas,

tnx

Showing 1 to 10 of 30 entries