Browse Source

feat: Add EF Workspace Model Config

pull/1421/head
colin 2 months ago
parent
commit
d5fe69de58
  1. 4
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContext.cs
  2. 23
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContextModelBuilderExtensions.cs
  3. 6
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/IAIManagementDbContext.cs

4
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContext.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using LINGYUN.Abp.AIManagement.Workspaces;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
@ -7,6 +8,7 @@ namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
[ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)]
public class AIManagementDbContext : AbpDbContext<AIManagementDbContext>, IAIManagementDbContext
{
public DbSet<Workspace> Workspaces { get; set; }
public AIManagementDbContext(
DbContextOptions<AIManagementDbContext> options) : base(options)
{

23
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContextModelBuilderExtensions.cs

@ -1,4 +1,5 @@
using JetBrains.Annotations;
using LINGYUN.Abp.AIManagement.Workspaces;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
@ -16,6 +17,28 @@ public static class AIManagementDbContextModelBuilderExtensions
return;
}
builder.Entity<Workspace>(b =>
{
b.ToTable(AbpAIManagementDbProperties.DbTablePrefix + "Workspaces", AbpAIManagementDbProperties.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name).HasMaxLength(WorkspaceConsts.MaxNameLength).IsRequired();
b.Property(x => x.Provider).HasMaxLength(WorkspaceConsts.MaxProviderLength).IsRequired();
b.Property(x => x.ModelName).HasMaxLength(WorkspaceConsts.MaxModelNameLength).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(WorkspaceConsts.MaxDisplayNameLength).IsRequired();
b.Property(x => x.Description).HasMaxLength(WorkspaceConsts.MaxDescriptionLength);
b.Property(x => x.ApiKey).HasMaxLength(WorkspaceConsts.MaxApiKeyLength);
b.Property(x => x.ApiBaseUrl).HasMaxLength(WorkspaceConsts.MaxApiKeyLength);
b.Property(x => x.SystemPrompt).HasMaxLength(WorkspaceConsts.MaxSystemPromptLength);
b.Property(x => x.Instructions).HasMaxLength(WorkspaceConsts.MaxInstructionsLength);
b.Property(x => x.StateCheckers).HasMaxLength(WorkspaceConsts.MaxStateCheckersLength);
b.HasIndex(x => new { x.Name }).IsUnique();
b.ApplyObjectExtensionMappings();
});
builder.TryConfigureObjectExtensions<AIManagementDbContext>();
}
}

6
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/IAIManagementDbContext.cs

@ -1,4 +1,6 @@
using Volo.Abp.Data;
using LINGYUN.Abp.AIManagement.Workspaces;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
@ -6,5 +8,5 @@ namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
[ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)]
public interface IAIManagementDbContext : IEfCoreDbContext
{
DbSet<Workspace> Workspaces { get; }
}

Loading…
Cancel
Save