mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Add database.
This commit is contained in:
56
RomRepoMgr.Database/Context.cs
Normal file
56
RomRepoMgr.Database/Context.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// Aaru Data Preservation Suite
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Context.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Database.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Entity framework database context.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2020 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace RomRepoMgr.Database
|
||||||
|
{
|
||||||
|
public sealed class Context : DbContext
|
||||||
|
{
|
||||||
|
public Context(DbContextOptions options) : base(options) {}
|
||||||
|
|
||||||
|
public static Context Create(string dbPath)
|
||||||
|
{
|
||||||
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
|
optionsBuilder.UseLazyLoadingProxies().UseSqlite($"Data Source={dbPath}");
|
||||||
|
|
||||||
|
return new Context(optionsBuilder.Options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
9
RomRepoMgr.Database/ContextFactory.cs
Normal file
9
RomRepoMgr.Database/ContextFactory.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Design;
|
||||||
|
|
||||||
|
namespace RomRepoMgr.Database
|
||||||
|
{
|
||||||
|
public class ContextFactory : IDesignTimeDbContextFactory<Context>
|
||||||
|
{
|
||||||
|
public Context CreateDbContext(string[] args) => Context.Create("romrepo.db");
|
||||||
|
}
|
||||||
|
}
|
||||||
22
RomRepoMgr.Database/Migrations/20200821221812_InitialMigration.Designer.cs
generated
Normal file
22
RomRepoMgr.Database/Migrations/20200821221812_InitialMigration.Designer.cs
generated
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using RomRepoMgr.Database;
|
||||||
|
|
||||||
|
namespace RomRepoMgr.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Context))]
|
||||||
|
[Migration("20200821221812_InitialMigration")]
|
||||||
|
partial class InitialMigration
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.7");
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace RomRepoMgr.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class InitialMigration : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) {}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs
Normal file
18
RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|
||||||
|
namespace RomRepoMgr.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Context))]
|
||||||
|
internal class ContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "3.1.7");
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
RomRepoMgr.Database/RomRepoMgr.Database.csproj
Normal file
22
RomRepoMgr.Database/RomRepoMgr.Database.csproj
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.7">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.7" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.7" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations" />
|
||||||
|
<Folder Include="Models" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RomRepoMgr", "RomRepoMgr\RomRepoMgr.csproj", "{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RomRepoMgr", "RomRepoMgr\RomRepoMgr.csproj", "{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RomRepoMgr.Database", "RomRepoMgr.Database\RomRepoMgr.Database.csproj", "{FE5ACD61-90F1-4B9F-9BDA-50934040882A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -12,5 +14,9 @@ Global
|
|||||||
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6CDCA6AF-B060-45AC-BCE2-CDBB0AF6B9AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FE5ACD61-90F1-4B9F-9BDA-50934040882A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FE5ACD61-90F1-4B9F-9BDA-50934040882A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FE5ACD61-90F1-4B9F-9BDA-50934040882A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FE5ACD61-90F1-4B9F-9BDA-50934040882A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -4,18 +4,18 @@
|
|||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Models\"/>
|
<Folder Include="Models\" />
|
||||||
<Compile Update="**\*.xaml.cs">
|
<Compile Update="**\*.xaml.cs">
|
||||||
<DependentUpon>%(Filename)</DependentUpon>
|
<DependentUpon>%(Filename)</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<AvaloniaResource Include="**\*.xaml">
|
<AvaloniaResource Include="**\*.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</AvaloniaResource>
|
</AvaloniaResource>
|
||||||
<AvaloniaResource Include="Assets\**"/>
|
<AvaloniaResource Include="Assets\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="0.9.12"/>
|
<PackageReference Include="Avalonia" Version="0.9.12" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="0.9.12"/>
|
<PackageReference Include="Avalonia.Desktop" Version="0.9.12" />
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.12"/>
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.12" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user