Hi Maliming,
Noted on that. As I still need some filtering by TenantId
, A possible workaround for me is to add TenantId
without implementing IMultiTenant
.
Is there any way to automatically populate this TenantId
field with the CurrentTenant
?
Thank you
Hi Maliming,
Just as context, our business requirement is that for some custom entities (e.g. AppBooks), that our data must reside only in the Host Database (even if tenant is using its own DB Connection String). But the data must still be accessible from the Tenant.
Is there a better way to achieve this outcome in the ABP framework?
Thank you
Thank you. The workaround I will then try is to implement a new DbContext class and apply the [IgnoreMultiTenancy]
attribute
I've Created a class called HostOnlyDbContext.cs
[ConnectionStringName("Default")]
[IgnoreMultiTenancy]
public class HostOnlyDbContext : AbpSolution4DbContextBase<HostOnlyDbContext>
{
public DbSet<Experience> Experiences { get; set; } = null!;
public HostOnlyDbContext(DbContextOptions<HostOnlyDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
builder.SetMultiTenancySide(MultiTenancySides.Both);
builder.Entity<Experience>(b =>
{
b.ToTable(AbpSolution4Consts.DbTablePrefix + "Experiences", AbpSolution4Consts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.TenantId).HasColumnName(nameof(Experience.TenantId));
b.Property(x => x.Name).HasColumnName(nameof(Experience.Name));
});
}
And also registered the DbContext in AbpSolution4EntityFrameworkCoreModule.cs
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<AbpSolution4DbContext>(options =>
{
/* Remove "includeAllEntities: true" to create
* default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true);
options.AddRepository<Conversation, Conversations.EfCoreConversationRepository>();
});
context.Services.AddAbpDbContext<HostOnlyDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
options.AddRepository<Experience, Experiences.EfCoreExperienceRepository>();
});
Would this work? I am having trouble understanding how the original AbpSolution4DbContext
is being injected and whether it is possible to reference AbpSolution4DbContext
for the Conversation
entity but use HostOnlyDbContext
for the Experience
entity.
also, is there a way to migrate BOTH the AbpSolution4DbContext
and HostOnlyDbContext
during DB Migration? Currently it is only running migrations for AbpSolution4DbContext
Hi Anjali,
It seems like the OP was asking about ignoring the [IgnoreMultiTenancy] decorator. My question is different, as I want to apply this [IgnoreMultiTenancy] decorator on an entity level.
Otherwise, we may need to create a new DbContext for all entities which are IMultiTenant but still use Host DB Context (Even if the Tenant has its own DB Connection String)
I am referencing these docs: https://abp.io/docs/latest/framework/data/entity-framework-core#controlling-the-multi-tenancy
I would like to ensure that some entities always uses the host connection string, even if I am in a tenant context.
Based on the documentation, this can be done on the DbContext level, where all DbSet<Entity> defined in that context will be only using the host connection string.
Question is if there is a way to define this [IgnoreMultiTenancy] flag on the Entity level. I saw that there is a check here:
however i tried adding [IgnoreMultiTenancy] to the Entity but it doens't seem to work e.g.
Is there something I am missing? Thanks
Hi Team,
I am using Angular but customizing the login pages on MVC.
How can i customize these components:
ok thank you
Thank you very much. Managed to get the customized login page up and running, however where can i find the layout page?
I cannot seem to remove my app name and language switcher although i can change the logo.
I understand that i need to add and edit a layout file somewhere but it is not in the downloaded source code (abp get-source Volo.Abp.Account.Pro)
Hi,
This is free version source code,
you can download account pro module source code:
abp get-source Volo.Abp.Account.Pro
can you point me to the correct documentation? thank you.
which do i install? https://abp.io/packages
I am looking for the login page.
Hi Team,
I followed instructions here to replace the login page (https://abp.io/docs/latest/framework/ui/mvc-razor-pages/customization-user-interface?_redirected=B8ABF606AA1BDF5C629883DF1061649A)
copied the source code from here as instructed by abp support -> https://github.com/abpframework/abp/blob/dev/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml#L61C11-L61C141
but am faced with these few errors:
Please help.