Added main entities
This commit is contained in:
parent
c93c903c26
commit
50ffcb33b1
@ -6,6 +6,12 @@ public sealed class DataContext : DbContext
|
|||||||
{
|
{
|
||||||
public DbSet<Setting>? Settings { get; set; }
|
public DbSet<Setting>? Settings { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Section>? Sections { get; set; }
|
||||||
|
|
||||||
|
public DbSet<TextElement>? TextElements { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Translation>? Translations { get; set; }
|
||||||
|
|
||||||
public DataContext(DbContextOptions<DataContext> contextOptions) : base(contextOptions)
|
public DataContext(DbContextOptions<DataContext> contextOptions) : base(contextOptions)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -14,7 +20,7 @@ public sealed class DataContext : DbContext
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
#region Ideas
|
#region Settings
|
||||||
|
|
||||||
modelBuilder.Entity<Setting>().HasIndex(n => n.Id);
|
modelBuilder.Entity<Setting>().HasIndex(n => n.Id);
|
||||||
modelBuilder.Entity<Setting>().HasIndex(n => n.Name).IsUnique();
|
modelBuilder.Entity<Setting>().HasIndex(n => n.Name).IsUnique();
|
||||||
@ -24,5 +30,27 @@ public sealed class DataContext : DbContext
|
|||||||
modelBuilder.Entity<Setting>().HasIndex(n => n.TextValue);
|
modelBuilder.Entity<Setting>().HasIndex(n => n.TextValue);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Sections
|
||||||
|
|
||||||
|
modelBuilder.Entity<Section>().HasIndex(n => n.Id);
|
||||||
|
modelBuilder.Entity<Section>().HasIndex(n => n.Name);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TextElements
|
||||||
|
|
||||||
|
modelBuilder.Entity<TextElement>().HasIndex(n => n.Id);
|
||||||
|
modelBuilder.Entity<TextElement>().HasIndex(n => n.Code);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Translations
|
||||||
|
|
||||||
|
modelBuilder.Entity<Translation>().HasIndex(n => n.Id);
|
||||||
|
modelBuilder.Entity<Translation>().HasIndex(n => n.Culture);
|
||||||
|
modelBuilder.Entity<Translation>().HasIndex(n => n.Text);
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
15
I18N Commander/DataModel/Database/Section.cs
Normal file
15
I18N Commander/DataModel/Database/Section.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DataModel.Database;
|
||||||
|
|
||||||
|
public sealed class Section
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Section Parent { get; set; }
|
||||||
|
|
||||||
|
public List<TextElement> TextElements { get; set; }
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace DataModel.Database;
|
namespace DataModel.Database;
|
||||||
|
|
||||||
public class Setting
|
public sealed class Setting
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
15
I18N Commander/DataModel/Database/TextElement.cs
Normal file
15
I18N Commander/DataModel/Database/TextElement.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DataModel.Database;
|
||||||
|
|
||||||
|
public sealed class TextElement
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Section Section { get; set; }
|
||||||
|
|
||||||
|
public List<Translation> Translations { get; set; }
|
||||||
|
}
|
12
I18N Commander/DataModel/Database/Translation.cs
Normal file
12
I18N Commander/DataModel/Database/Translation.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace DataModel.Database;
|
||||||
|
|
||||||
|
public sealed class Translation
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public TextElement TextElement { get; set; }
|
||||||
|
|
||||||
|
public string Culture { get; set; } = "en-US";
|
||||||
|
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user