I cannot share my project and will take too long to create a sample with the right conditions. My use case is very simple: Is it possible to tell the ObjectExtensionManager that the mappings are just for the Tenant and not for the host? Just like when creating the model builder.SetMultiTenancySide(MultiTenancySides.Tenant);
Or is there any other way to add the additional columns to the AbpUsers table?
Hello, I need to extend the IdentityUser just for the tenants, I'm using the EfCoreEntityExtensionMappings class but when I run the migration I get an error because I assume that one of the foreign keys to a table that only exists in the tenant databases is not present in the host. How can I just extend the IdentityUser just for the tenants?
Extension mapping code here:
using CompuCare.Entities;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
namespace CompuCare.EntityFrameworkCore;
public static class CompuCareEfCoreEntityExtensionMappings
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure()
{
CompuCareGlobalFeatureConfigurator.Configure();
CompuCareModuleExtensionConfigurator.Configure();
OneTimeRunner.Run(() =>
{
ObjectExtensionManager.Instance
.MapEfCoreProperty<IdentityUser, string>(
"SSN",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.HasMaxLength(9);
}
)
.MapEfCoreProperty<IdentityUser, int?>(
"DoctorId",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.IsRequired(false);
entityBuilder.HasOne(typeof(Entities.Doctor))
.WithMany()
.IsRequired(false);
}
)
.MapEfCoreProperty<IdentityUser, int?>(
"TypeId",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.IsRequired(false);
entityBuilder.HasOne(typeof(Entities.Type))
.WithMany()
.IsRequired(false);
}
);
});
}
}
Migration that was created:
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompuCare.TenantMigrations
{
/// <inheritdoc />
public partial class IdentityUserExtraProperties : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "DoctorId",
table: "AbpUsers",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SSN",
table: "AbpUsers",
type: "nvarchar(9)",
maxLength: 9,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "TypeId",
table: "AbpUsers",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_DoctorId",
table: "AbpUsers",
column: "DoctorId");
migrationBuilder.CreateIndex(
name: "IX_AbpUsers_TypeId",
table: "AbpUsers",
column: "TypeId");
migrationBuilder.AddForeignKey(
name: "FK_AbpUsers_Doctors_DoctorId",
table: "AbpUsers",
column: "DoctorId",
principalTable: "Doctors",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AbpUsers_Types_TypeId",
table: "AbpUsers",
column: "TypeId",
principalTable: "Types",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AbpUsers_Doctors_DoctorId",
table: "AbpUsers");
migrationBuilder.DropForeignKey(
name: "FK_AbpUsers_Types_TypeId",
table: "AbpUsers");
migrationBuilder.DropIndex(
name: "IX_AbpUsers_DoctorId",
table: "AbpUsers");
migrationBuilder.DropIndex(
name: "IX_AbpUsers_TypeId",
table: "AbpUsers");
migrationBuilder.DropColumn(
name: "DoctorId",
table: "AbpUsers");
migrationBuilder.DropColumn(
name: "SSN",
table: "AbpUsers");
migrationBuilder.DropColumn(
name: "TypeId",
table: "AbpUsers");
}
}
}
I'm trying to create an entity with a DateOnly field type, but when creating a migration I'm getting the following message:
The 'DateOnly?' property 'AccountingDeposit.BankPostingDate' could not be mapped to the database type 'date' because the database provider does not support mapping 'DateOnly?' properties to 'date' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
I'm using a value converter as suggested.
protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{
builder.Properties<DateOnly>()
.HaveConversion<DateOnlyConverter>()
.HaveColumnType("date");
base.ConfigureConventions(builder);
}
Please advice on how to proceed.
I think I figured it out, thank you. Would I take the same approach to host a Hangfire server independently from the main API?
Trying to create the service as suggested but getting an error that says: Could not find a part of the path 'C:\Repos\CompuCare\aspnet-core\apps\auth-server'.
Will this work if I'm not using a microservice architecture?
Need guidance on the following: I need to create a separate application for report processing but need to be able to authenticate and read the claims of the user requesting the reports using the same credentials from the application to be able to know the tenantid and connect to the right database. The reports will be displayed in the angular application in an iframe.
When is the next version going to be released? Please update my support incident allowance since this is a bug. Thank you.
It's been almost 10 days for what should be a simple answer, please let me know if your documentation is incorrect and if this can not be done or provide a workaround to replace the Logo component.
Thank you,
Any update on this issue? I need to get this resolved ASAP.