added initial migration

This commit is contained in:
2018-12-10 00:37:20 +01:00
parent 4480e219fa
commit 858a694eeb
5 changed files with 132 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Tv7Playlist.Data;
namespace Tv7Playlist.Data.Migrations
{
[DbContext(typeof(PlaylistContext))]
[Migration("20181209233600_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687");
modelBuilder.Entity("Tv7Playlist.Data.PlaylistEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<int>("TrackNumber");
b.Property<string>("Url");
b.HasKey("Id");
b.HasAlternateKey("TrackNumber");
b.ToTable("PlaylistEntries");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Tv7Playlist.Data.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PlaylistEntries",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
TrackNumber = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
Url = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlaylistEntries", x => x.Id);
table.UniqueConstraint("AK_PlaylistEntries_TrackNumber", x => x.TrackNumber);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PlaylistEntries");
}
}
}

View File

@@ -0,0 +1,39 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Tv7Playlist.Data;
namespace Tv7Playlist.Data.Migrations
{
[DbContext(typeof(PlaylistContext))]
partial class PlaylistContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687");
modelBuilder.Entity("Tv7Playlist.Data.PlaylistEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<int>("TrackNumber");
b.Property<string>("Url");
b.HasKey("Id");
b.HasAlternateKey("TrackNumber");
b.ToTable("PlaylistEntries");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Tv7Playlist.Data
{
public class PlaylistContextFactory : IDesignTimeDbContextFactory<PlaylistContext>
{
public PlaylistContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<PlaylistContext>();
optionsBuilder.UseSqlite("Data Source=designPlaylist.db");
return new PlaylistContext(optionsBuilder.Options);
}
}
}

View File

@@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
</ItemGroup>
</Project>