-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.cs
48 lines (40 loc) · 1.38 KB
/
Model.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
public class RecordCollectionContext : DbContext
{
public DbSet<Record> Record { get; set; }
public DbSet<ProductCompany> Producter { get; set; }
public string DbPath { get; }
public RecordCollectionContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "record-database.db");
}
// The following configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
//
// /username/.local/share
//
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
}
public class Record
{
public int ID { get; set; }
public string? Artist { get; set; }
public string? Title { get; set; }
public string? Genre { get; set; }
public string? ExtraInformation { get; set; }
public int? Year { get; set; }
public virtual ProductCompany? ProductCompany { get; set; }
}
// This is record label
public class ProductCompany
{
public int ID { get; set; }
public string? Name { get; set; }
public virtual ICollection<Record>? Records { get; set; }
}