mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Add files table.
This commit is contained in:
@@ -1,36 +1,30 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
/******************************************************************************
|
||||
// RomRepoMgr - ROM repository manager
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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.
|
||||
// This program 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 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/>.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
// Copyright © 2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RomRepoMgr.Database.Models;
|
||||
|
||||
namespace RomRepoMgr.Database
|
||||
{
|
||||
@@ -38,6 +32,8 @@ namespace RomRepoMgr.Database
|
||||
{
|
||||
public Context(DbContextOptions options) : base(options) {}
|
||||
|
||||
public DbSet<DbFile> Files { get; set; }
|
||||
|
||||
public static Context Create(string dbPath)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder();
|
||||
@@ -46,11 +42,20 @@ namespace RomRepoMgr.Database
|
||||
return new Context(optionsBuilder.Options);
|
||||
}
|
||||
|
||||
/*
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
*/
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<DbFile>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.Crc32);
|
||||
|
||||
entity.HasIndex(e => e.Sha1);
|
||||
|
||||
entity.HasIndex(e => e.Sha256);
|
||||
|
||||
entity.HasIndex(e => e.Size);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user