mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
code-first migration
This commit is contained in:
parent
4dfe9f1820
commit
41b6926631
5 changed files with 141 additions and 4 deletions
|
|
@ -5,6 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
|
||||
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
52
api/FilterLists.Data/Migrations/20170409192934_FilterListsMigration.Designer.cs
generated
Normal file
52
api/FilterLists.Data/Migrations/20170409192934_FilterListsMigration.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using FilterLists.Data.Contexts;
|
||||
|
||||
namespace FilterLists.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(FilterListsDbContext))]
|
||||
[Migration("20170409192934_FilterListsMigration")]
|
||||
partial class FilterListsMigration
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "1.1.1");
|
||||
|
||||
modelBuilder.Entity("FilterLists.Models.List", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedDate");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<string>("DescriptionSourceUrl");
|
||||
|
||||
b.Property<string>("DonateUrl");
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("ForumUrl");
|
||||
|
||||
b.Property<string>("HomeUrl");
|
||||
|
||||
b.Property<string>("IssuesUrl");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ViewUrl");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("List");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace FilterLists.Data.Migrations
|
||||
{
|
||||
public partial class FilterListsMigration : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
"List",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<long>(nullable: false)
|
||||
.Annotation("MySQL:AutoIncrement", true),
|
||||
AddedDate = table.Column<DateTime>(nullable: false),
|
||||
Description = table.Column<string>(nullable: true),
|
||||
DescriptionSourceUrl = table.Column<string>(nullable: true),
|
||||
DonateUrl = table.Column<string>(nullable: true),
|
||||
Email = table.Column<string>(nullable: true),
|
||||
ForumUrl = table.Column<string>(nullable: true),
|
||||
HomeUrl = table.Column<string>(nullable: true),
|
||||
IssuesUrl = table.Column<string>(nullable: true),
|
||||
ModifiedDate = table.Column<DateTime>(nullable: false),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
ViewUrl = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_List", x => x.Id); });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
"List");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using FilterLists.Data.Contexts;
|
||||
|
||||
namespace FilterLists.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(FilterListsDbContext))]
|
||||
partial class FilterListsDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "1.1.1");
|
||||
|
||||
modelBuilder.Entity("FilterLists.Models.List", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedDate");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<string>("DescriptionSourceUrl");
|
||||
|
||||
b.Property<string>("DonateUrl");
|
||||
|
||||
b.Property<string>("Email");
|
||||
|
||||
b.Property<string>("ForumUrl");
|
||||
|
||||
b.Property<string>("HomeUrl");
|
||||
|
||||
b.Property<string>("IssuesUrl");
|
||||
|
||||
b.Property<DateTime>("ModifiedDate");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ViewUrl");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("List");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,11 @@
|
|||
//https://code.msdn.microsoft.com/Generic-Repository-Pattern-f133bca4/sourcecode?fileId=164016&pathId=1938870460
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FilterLists.Models
|
||||
{
|
||||
public class BaseEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
public DateTime AddedDate { get; set; }
|
||||
public DateTime ModifiedDate { get; set; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue