using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using NexusReader.Domain.Enums; namespace NexusReader.Domain.Entities; public class KnowledgeUnit { [Key] [MaxLength(128)] public string Id { get; set; } = string.Empty; // Hash(Source + Content + Version) public Guid? EbookId { get; set; } [ForeignKey(nameof(EbookId))] public virtual Ebook? Ebook { get; set; } [Required] [MaxLength(50)] public string Version { get; set; } = "1.0"; [Required] public KnowledgeUnitType Type { get; set; } [Required] public string Content { get; set; } = string.Empty; public string? MetadataJson { get; set; } // e.g. { "page": 1, "path": "Chapter 1 > Intro" } [Required] [MaxLength(128)] public string TenantId { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; // Relationships public ICollection OutgoingLinks { get; set; } = new List(); public ICollection IncomingLinks { get; set; } = new List(); }