< 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: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 50
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
.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;
 2
 3namespace Elsa.AI.Persistence.EFCore;
 4
 385public class AIDbContext(DbContextOptions<AIDbContext> options) : DbContext(options)
 6{
 587    public DbSet<AIConversationRecord> Conversations => Set<AIConversationRecord>();
 408    public DbSet<AIProposalRecord> Proposals => Set<AIProposalRecord>();
 109    public DbSet<AIAuditRecord> AuditRecords => Set<AIAuditRecord>();
 10
 11    protected override void OnModelCreating(ModelBuilder modelBuilder)
 12    {
 213        modelBuilder.Entity<AIProposalRecord>(entity =>
 214        {
 215            entity.ToTable("AIProposals");
 216            entity.HasKey(x => x.Id);
 217            entity.HasIndex(x => new { x.TenantId, x.ConversationId });
 218            entity.HasIndex(x => x.Status);
 219            entity.Property(x => x.WorkflowPayload).IsRequired();
 220            entity.Property(x => x.ValidationDiagnostics).IsRequired();
 221            entity.Property(x => x.Warnings).IsRequired();
 422        });
 23
 224        modelBuilder.Entity<AIAuditRecord>(entity =>
 225        {
 226            entity.ToTable("AIAuditRecords");
 227            entity.HasKey(x => x.Id);
 228            entity.HasIndex(x => new { x.TenantId, x.ConversationId });
 229            entity.HasIndex(x => x.ActorId);
 230            entity.HasIndex(x => new { x.TenantId, x.Timestamp });
 231            entity.HasIndex(x => x.ProposalId);
 232            entity.HasIndex(x => x.ToolInvocationId);
 233            entity.Property(x => x.Type).IsRequired();
 234            entity.Property(x => x.Data).IsRequired();
 435        });
 36
 237        modelBuilder.Entity<AIConversationRecord>(entity =>
 238        {
 239            entity.ToTable("AIConversations");
 240            entity.HasKey(x => x.Id);
 241            entity.HasIndex(x => new { x.TenantId, x.UserId });
 242            entity.HasIndex(x => x.Status);
 243            entity.HasIndex(x => x.RetentionExpiresAt);
 244            entity.Property(x => x.UserId).IsRequired();
 245            entity.Property(x => x.Status).IsRequired();
 246            entity.Property(x => x.RetentionMode).IsRequired();
 247            entity.Property(x => x.Messages).IsRequired();
 448        });
 249    }
 50}