Added data context
This commit is contained in:
parent
8c82f2608e
commit
19b9851832
@ -7,4 +7,18 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
28
I18N Commander/DataModel/Database/Common/DataContext.cs
Normal file
28
I18N Commander/DataModel/Database/Common/DataContext.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DataModel.Database.Common;
|
||||
|
||||
public sealed class DataContext : DbContext
|
||||
{
|
||||
public DbSet<Setting>? Settings { get; set; }
|
||||
|
||||
public DataContext(DbContextOptions<DataContext> contextOptions) : base(contextOptions)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
#region Ideas
|
||||
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.Id);
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.Name).IsUnique();
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.BoolValue);
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.GuidValue);
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.IntegerValue);
|
||||
modelBuilder.Entity<Setting>().HasIndex(n => n.TextValue);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user