switched mysql provider

This commit is contained in:
Collin M. Barrett 2017-04-10 06:23:42 -05:00
parent ecd2ceb8db
commit 5f01f9eab9
9 changed files with 314 additions and 21 deletions

View file

@ -12,7 +12,6 @@
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />

View file

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
<PackageReference Include="SapientGuardian.EntityFrameworkCore.MySql" Version="7.1.23" />
</ItemGroup>
<ItemGroup>

View file

@ -0,0 +1,64 @@
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("20170410020231_AddListAnnotations")]
partial class AddListAnnotations
{
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>("AddedDateUtc")
.ValueGeneratedOnAdd();
b.Property<string>("Description")
.HasMaxLength(512);
b.Property<string>("DescriptionSourceUrl")
.HasMaxLength(6);
b.Property<string>("DonateUrl")
.HasMaxLength(6);
b.Property<string>("Email")
.HasMaxLength(7);
b.Property<string>("ForumUrl")
.HasMaxLength(6);
b.Property<string>("HomeUrl")
.HasMaxLength(6);
b.Property<string>("IssuesUrl")
.HasMaxLength(6);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate();
b.Property<string>("Name")
.HasMaxLength(64);
b.Property<string>("ViewUrl")
.IsRequired()
.HasMaxLength(6);
b.HasKey("Id");
b.ToTable("List");
});
}
}
}

View file

@ -0,0 +1,181 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace FilterLists.Data.Migrations
{
public partial class AddListAnnotations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.DropColumn(
// name: "AddedDate",
// table: "List");
//migrationBuilder.DropColumn(
// "ModifiedDate",
// "List");
migrationBuilder.AlterColumn<string>(
"ViewUrl",
"List",
maxLength: 6,
nullable: false,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"Name",
"List",
maxLength: 64,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"IssuesUrl",
"List",
maxLength: 6,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"HomeUrl",
"List",
maxLength: 6,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"ForumUrl",
"List",
maxLength: 6,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"Email",
"List",
maxLength: 7,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"DonateUrl",
"List",
maxLength: 6,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"DescriptionSourceUrl",
"List",
maxLength: 6,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AddColumn<DateTime>(
"AddedDateUtc",
"List",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
"ModifiedDateUtc",
"List",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
"AddedDateUtc",
"List");
migrationBuilder.DropColumn(
"ModifiedDateUtc",
"List");
migrationBuilder.AlterColumn<string>(
"ViewUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6);
migrationBuilder.AlterColumn<string>(
"Name",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 64,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"IssuesUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"HomeUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"ForumUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"Email",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 7,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"DonateUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
"DescriptionSourceUrl",
"List",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 6,
oldNullable: true);
migrationBuilder.AddColumn<DateTime>(
"AddedDate",
"List",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
"ModifiedDate",
"List",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
}
}

View file

@ -20,27 +20,39 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AddedDate");
b.Property<DateTime>("AddedDateUtc")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<string>("Description")
.HasMaxLength(512);
b.Property<string>("DescriptionSourceUrl");
b.Property<string>("DescriptionSourceUrl")
.HasMaxLength(6);
b.Property<string>("DonateUrl");
b.Property<string>("DonateUrl")
.HasMaxLength(6);
b.Property<string>("Email");
b.Property<string>("Email")
.HasMaxLength(7);
b.Property<string>("ForumUrl");
b.Property<string>("ForumUrl")
.HasMaxLength(6);
b.Property<string>("HomeUrl");
b.Property<string>("HomeUrl")
.HasMaxLength(6);
b.Property<string>("IssuesUrl");
b.Property<string>("IssuesUrl")
.HasMaxLength(6);
b.Property<DateTime>("ModifiedDate");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate();
b.Property<string>("Name");
b.Property<string>("Name")
.HasMaxLength(64);
b.Property<string>("ViewUrl");
b.Property<string>("ViewUrl")
.IsRequired()
.HasMaxLength(6);
b.HasKey("Id");

View file

@ -1,13 +1,23 @@
//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
public abstract class BaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public DateTime AddedDate { get; set; }
public DateTime ModifiedDate { get; set; }
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public DateTime AddedDateUtc { get; set; }
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime ModifiedDateUtc { get; set; }
}
}

View file

@ -4,8 +4,4 @@
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
</ItemGroup>
</Project>

View file

@ -1,15 +1,42 @@
namespace FilterLists.Models
using System.ComponentModel.DataAnnotations;
namespace FilterLists.Models
{
public class List : BaseEntity
{
[MaxLength(512)]
public string Description { get; set; }
[MaxLength(6)]
[MinLength(2083)]
public string DescriptionSourceUrl { get; set; }
[MaxLength(6)]
[MinLength(2083)]
public string DonateUrl { get; set; }
[MaxLength(7)]
[MinLength(254)]
public string Email { get; set; }
[MaxLength(6)]
[MinLength(2083)]
public string ForumUrl { get; set; }
[MaxLength(6)]
[MinLength(2083)]
public string HomeUrl { get; set; }
[MaxLength(6)]
[MinLength(2083)]
public string IssuesUrl { get; set; }
[MaxLength(64)]
public string Name { get; set; }
[Required]
[MaxLength(6)]
[MinLength(2083)]
public string ViewUrl { get; set; }
}
}

View file

@ -4,6 +4,10 @@
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FilterLists.Data.Contracts\FilterLists.Data.Contracts.csproj" />
<ProjectReference Include="..\FilterLists.Models\FilterLists.Models.csproj" />