added new projects and some base code for persistence
This commit is contained in:
23
Tv7Playlist.Data/PlaylistContext.cs
Normal file
23
Tv7Playlist.Data/PlaylistContext.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Tv7Playlist.Data
|
||||
{
|
||||
public class PlaylistContext : DbContext
|
||||
{
|
||||
public PlaylistContext(DbContextOptions<PlaylistContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<PlaylistEntry> PlaylistEntries { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
var entityTypeBuilder = modelBuilder.Entity<PlaylistEntry>();
|
||||
entityTypeBuilder.HasKey(e => e.Id);
|
||||
entityTypeBuilder.HasAlternateKey(e => e.TrackNumber);
|
||||
}
|
||||
}
|
||||
}
|
15
Tv7Playlist.Data/PlaylistEntry.cs
Normal file
15
Tv7Playlist.Data/PlaylistEntry.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Tv7Playlist.Data
|
||||
{
|
||||
public class PlaylistEntry
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public int TrackNumber { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
12
Tv7Playlist.Data/Tv7Playlist.Data.csproj
Normal file
12
Tv7Playlist.Data/Tv7Playlist.Data.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user