< Summary

Information
Class: Elsa.AI.Persistence.EFCore.AIDbContext
Assembly: Elsa.AI.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.AI.Persistence.EFCore/AIDbContext.cs
Line coverage
100%
Covered lines: 44
Uncovered lines: 0
Coverable lines: 44
Total lines: 64
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
get_Conversations()100%11100%
get_Proposals()100%11100%
get_AuditRecords()100%11100%
OnModelCreating(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.AI.Persistence.EFCore/AIDbContext.cs

#LineLine coverage
 1using Elsa.AI.Persistence.EFCore.Entities;
 2using Elsa.Persistence.EFCore;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Elsa.AI.Persistence.EFCore;
 6
 7public class AIDbContext : ElsaDbContextBase
 8{
 19    private static readonly IServiceProvider EmptyServiceProvider = new ServiceCollection().BuildServiceProvider();
 10
 3411    public AIDbContext(DbContextOptions<AIDbContext> options) : this(options, EmptyServiceProvider)
 12    {
 3413    }
 14
 3815    public AIDbContext(DbContextOptions<AIDbContext> options, IServiceProvider serviceProvider) : base(options, serviceP
 16    {
 3817    }
 18
 5819    public DbSet<AIConversationRecord> Conversations => Set<AIConversationRecord>();
 4020    public DbSet<AIProposalRecord> Proposals => Set<AIProposalRecord>();
 1021    public DbSet<AIAuditRecord> AuditRecords => Set<AIAuditRecord>();
 22
 23    protected override void OnModelCreating(ModelBuilder modelBuilder)
 24    {
 225        modelBuilder.Entity<AIProposalRecord>(entity =>
 226        {
 227            entity.ToTable("AIProposals");
 228            entity.HasKey(x => x.Id);
 229            entity.HasIndex(x => new { x.TenantId, x.ConversationId });
 230            entity.HasIndex(x => x.Status);
 231            entity.Property(x => x.WorkflowPayload).IsRequired();
 232            entity.Property(x => x.ValidationDiagnostics).IsRequired();
 233            entity.Property(x => x.Warnings).IsRequired();
 434        });
 35
 236        modelBuilder.Entity<AIAuditRecord>(entity =>
 237        {
 238            entity.ToTable("AIAuditRecords");
 239            entity.HasKey(x => x.Id);
 240            entity.HasIndex(x => new { x.TenantId, x.ConversationId });
 241            entity.HasIndex(x => x.ActorId);
 242            entity.HasIndex(x => new { x.TenantId, x.Timestamp });
 243            entity.HasIndex(x => x.ProposalId);
 244            entity.HasIndex(x => x.ToolInvocationId);
 245            entity.Property(x => x.Type).IsRequired();
 246            entity.Property(x => x.Data).IsRequired();
 447        });
 48
 249        modelBuilder.Entity<AIConversationRecord>(entity =>
 250        {
 251            entity.ToTable("AIConversations");
 252            entity.HasKey(x => x.Id);
 253            entity.HasIndex(x => new { x.TenantId, x.UserId });
 254            entity.HasIndex(x => x.Status);
 255            entity.HasIndex(x => x.RetentionExpiresAt);
 256            entity.Property(x => x.UserId).IsRequired();
 257            entity.Property(x => x.Status).IsRequired();
 258            entity.Property(x => x.RetentionMode).IsRequired();
 259            entity.Property(x => x.Messages).IsRequired();
 460        });
 61
 262        base.OnModelCreating(modelBuilder);
 263    }
 64}