feat: Implementa gestione intelligente della chiave sorgente con rilevamento PK
- Aggiunge rilevamento automatico Primary Key per connessioni database - Rimuove completamente il fallback automatico per lato sorgente - Implementa selezione manuale obbligatoria per file e sorgenti non-DB - Migliora UI con suggerimenti intelligenti e feedback visivo - Aggiunge validazione multi-livello (UI, pre-transfer, runtime) - Introduce metodo GetPrimaryKeyFieldAsync in IDatabaseManager - Modifica GenerateSourceKey per richiedere sempre campo specifico - Implementa controllo IsTransferButtonEnabled per validazione form Breaking changes: - La generazione automatica delle chiavi sorgente è stata rimossa - Il campo chiave sorgente è ora obbligatorio quando si usa il sistema associazioni Fixes: Risolve problema di discovery schema vuoto con selezione database
This commit is contained in:
@@ -9,6 +9,7 @@ namespace CredentialManager.Data;
|
||||
public class CredentialDbContext : DbContext
|
||||
{
|
||||
public DbSet<CredentialEntity> Credentials { get; set; }
|
||||
public DbSet<RecordAssociation> RecordAssociations { get; set; }
|
||||
|
||||
public CredentialDbContext(DbContextOptions<CredentialDbContext> options) : base(options)
|
||||
{
|
||||
@@ -84,5 +85,55 @@ public class CredentialDbContext : DbContext
|
||||
|
||||
entity.HasIndex(e => e.IsActive);
|
||||
});
|
||||
|
||||
// Configurazione della tabella RecordAssociations
|
||||
modelBuilder.Entity<RecordAssociation>(entity =>
|
||||
{
|
||||
entity.ToTable("RecordAssociations");
|
||||
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.SourceName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.SourceType)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.SourceKey)
|
||||
.IsRequired()
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.DestinationEntity)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.DestinationId)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.RestCredentialName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.AdditionalInfo)
|
||||
.HasMaxLength(2000);
|
||||
|
||||
// Valori di default
|
||||
entity.Property(e => e.IsActive)
|
||||
.HasDefaultValue(true);
|
||||
|
||||
// Indici
|
||||
entity.HasIndex(e => new { e.SourceName, e.SourceKey, e.DestinationEntity })
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_RecordAssociations_Unique");
|
||||
|
||||
entity.HasIndex(e => e.SourceType);
|
||||
entity.HasIndex(e => e.DestinationEntity);
|
||||
entity.HasIndex(e => e.RestCredentialName);
|
||||
entity.HasIndex(e => e.IsActive);
|
||||
entity.HasIndex(e => e.CreatedAt);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user