Crestapps core entitycore stores

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core entitycore stores is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the CrestApps.Core.Data.EntityCore persistence backend in CrestApps.Core 2.0. Covers AddEntityCoreSqliteDataStore and AddEntityCoreDataStore with any EF Core provider, EntityCoreDataStoreOptions (TablePrefix, EnforceNamedSourceUniqueness), CrestAppsEntityDbContext and its tables, EntityCor

How to use this skill

Skill file

CrestApps.Core EntityCore Stores

You are a CrestApps.Core expert. Generate accurate Entity Framework Core persistence code with CrestApps.Core.Data.EntityCore.

Rules

Registration

using CrestApps.Core;
using CrestApps.Core.AI;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Documents;
using CrestApps.Core.Data.EntityCore;

builder.Services.AddControllersWithViews()
    .AddCrestAppsStoreCommitterFilter();

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddEntityCoreStores()
        .AddChatInteractions(chat => chat.AddEntityCoreStores())
        .AddDocumentProcessing(documents => documents.AddEntityCoreStores())
        .AddAIMemory(memory => memory.AddEntityCoreStores())
        .AddPersonas(personas => personas.AddEntityCoreStores())
        .AddToolInstances(tools => tools.AddEntityCoreStores()))
    .AddIndexingServices(indexing => indexing.AddEntityCoreStores())
    .AddEntityCoreDataStore(
        options => options.UseNpgsql(builder.Configuration.GetConnectionString("CrestApps")),
        store => store.TablePrefix = "App_"));

builder.Services.AddCoreWebCrawlerStoresEntityCore();
builder.Services.AddCoreFileSourceStoresEntityCore();

AddEntityCoreStores() also exists on CrestAppsA2AClientBuilder, CrestAppsMcpClientBuilder and CrestAppsMcpServerBuilder.

Service-Collection Methods

| Method | Registers |

|---|---|

| AddCoreAIServicesStoresEntityCore() | EntityCoreAIProfileStore as IAIProfileStore and every AIProfile catalog interface; writable binding sources for AIProviderConnection and AIDeployment |

| AddCoreAIProfileTemplateStoresEntityCore() | AIProfileTemplate named-source catalog |

| AddCoreAIPersonaStoresEntityCore() | AIPersona named catalog |

| AddCoreAIProfileVersionStoresEntityCore() | EntityCoreAIProfileVersionStore as IAIProfileVersionStore (also AddProfileVersions(v => v.AddEntityCoreStores())) |

| AddCoreAIToolInstanceStoresEntityCore() | AIToolInstance named-source catalog |

| AddCoreAIA2AClientStoresEntityCore() | A2AConnection catalog |

| AddCoreAIMcpClientStoresEntityCore() | McpConnection source catalog |

| AddCoreAIMcpServerStoresEntityCore() | McpPrompt named catalog, McpResource source catalog |

| AddCoreAIChatSessionStoresEntityCore() | EntityCoreAIChatSessionManager, EntityCoreAIChatSessionStore, EntityCoreAIChatSessionPromptStore, EntityCoreAIChatSessionEventStore, EntityCoreAICompletionUsageStore, and the extracted-data store |

| AddCoreAIChatSessionExtractedDataStoresEntityCore() | EntityCoreAIChatSessionExtractedDataStore and the extracted-data recorder |

| AddCoreAIChatInteractionStoresEntityCore() | ChatInteraction catalog, EntityCoreChatInteractionPromptStore |

| AddCoreAIDocumentProcessingStoresEntityCore() | EntityCoreAIDocumentStore, EntityCoreAIDocumentChunkStore |

| AddCoreAIDataSourceStoresEntityCore() | EntityCoreAIDataSourceStore |

| AddCoreAIMemoryStoresEntityCore() | EntityCoreAIMemoryStore |

| AddCoreIndexingStoresEntityCore() | EntityCoreSearchIndexProfileStore |

| AddCoreKnowledgeStoresEntityCore() | EntityCoreKnowledgeObjectStore as IKnowledgeObjectStore |

| AddCoreIngestionItemStateStoreEntityCore() | EntityCoreIngestionItemStateStore as IIngestionItemStateStore |

| AddCoreWebCrawlerStoresEntityCore() | EntityCoreWebCrawlerStore, EntityCoreWebCrawlStateStore, plus knowledge and ingestion item state |

| AddCoreFileSourceStoresEntityCore() | EntityCoreFileSourceStore, plus knowledge and ingestion item state |

services.AddEntityCoreStores() is a one-call shortcut that runs AddCatalogManagers() and the services, tool instance, profile template, A2A, MCP client, MCP server, chat session, document processing, data source, memory, chat interaction and indexing methods. It does not include personas, profile versions, knowledge objects, ingestion item state, web crawlers or file sources; add those explicitly.

Tables

CrestAppsEntityDbContext maps Documents, CatalogRecords, AIChatSessions, AIChatSessionEvents, AICompletionUsage and AIChatSessionExtractedData, each prefixed with TablePrefix. Catalog models are stored as JSON in Documents and indexed through CatalogRecords (entity type, item id, name, display text, source, and lookup columns). The context exposes them as Documents, CatalogRecords, AIChatSessionRecords, AIChatSessionEventRecords, AICompletionUsageRecords and AIChatSessionExtractedDataRecords.

Custom Models

Generic catalogs in CrestApps.Core.Data.EntityCore.Services store any CatalogItem in the shared tables with no schema change:

using CrestApps.Core;
using CrestApps.Core.Data.EntityCore.Services;

builder.Services.AddDocumentCatalog<Article, DocumentCatalog<Article>>();
builder.Services.AddNamedDocumentCatalog<TicketCategory, NamedDocumentCatalog<TicketCategory>>();
builder.Services.AddSourceDocumentCatalog<Connector, SourceDocumentCatalog<Connector>>();
builder.Services.AddNamedSourceDocumentCatalog<Widget, NamedSourceDocumentCatalog<Widget>>();

For a model that merges configuration and database entries, register the database side with AddEntityCoreNamedSourceBindingSource<TModel>() (named and source-aware) or AddEntityCoreNamedBindingSource<TModel>() (named only).

Extend the Model

using CrestApps.Core.Data.EntityCore;
using Microsoft.EntityFrameworkCore;

namespace MyApp.Data;

public sealed class AuditEntry
{
    public int Id { get; set; }

    public string ItemId { get; set; }

    public DateTime CreatedUtc { get; set; }
}

public sealed class AuditModelConfigurer : ICrestAppsModelConfigurer
{
    public void Configure(ModelBuilder modelBuilder, EntityCoreDataStoreOptions options)
    {
        modelBuilder.Entity<AuditEntry>(entity =>
        {
            entity.ToTable($"{options.TablePrefix}AuditEntries");
            entity.HasKey(entry => entry.Id);
            entity.HasIndex(entry => entry.ItemId);
        });
    }
}
builder.Services.AddSingleton<ICrestAppsModelConfigurer, AuditModelConfigurer>();

Configurers run inside OnModelCreating in registration order. Access the table through dbContext.Set<AuditEntry>(). EnsureCreatedAsync() creates tables only for a new database, so add tables to an existing database with a migration or your own script.

Troubleshooting

Upgrading Within 2.0 Previews

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.