Files
Data-Coupler/TestDatabaseFix/Program.cs
T
Alessio 51c61eabf7 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
2025-06-28 02:05:59 +02:00

51 lines
1.8 KiB
C#

using CredentialManager.Data;
using CredentialManager.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace TestDatabaseFix;
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Test Database Initialization Fix");
var services = new ServiceCollection();
services.AddLogging(builder => builder.AddConsole());
// Configura il DbContext per usare SQLite
services.AddDbContext<CredentialDbContext>(options =>
options.UseSqlite("Data Source=test_credentials.db"));
services.AddScoped<DatabaseInitializer>();
var serviceProvider = services.BuildServiceProvider();
using var scope = serviceProvider.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<CredentialDbContext>();
var initializer = scope.ServiceProvider.GetRequiredService<DatabaseInitializer>();
try
{
Console.WriteLine("Inizializzando il database...");
await initializer.InitializeAsync();
Console.WriteLine("Verifica tabelle...");
var credentialsCount = await dbContext.Credentials.CountAsync();
var associationsCount = await dbContext.RecordAssociations.CountAsync();
Console.WriteLine($"Tabella Credentials: {credentialsCount} record");
Console.WriteLine($"Tabella RecordAssociations: {associationsCount} record");
Console.WriteLine("Test completato con successo!");
}
catch (Exception ex)
{
Console.WriteLine($"Errore: {ex.Message}");
Console.WriteLine($"Stack trace: {ex.StackTrace}");
}
}
}