mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
annotation updates
This commit is contained in:
parent
acf3066d32
commit
940f0b8327
3 changed files with 87 additions and 0 deletions
64
api/FilterLists.Data/Migrations/20170410130859_SetDefaultDateValue.Designer.cs
generated
Normal file
64
api/FilterLists.Data/Migrations/20170410130859_SetDefaultDateValue.Designer.cs
generated
Normal 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("20170410130859_SetDefaultDateValue")]
|
||||
partial class SetDefaultDateValue
|
||||
{
|
||||
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(2083);
|
||||
|
||||
b.Property<string>("DonateUrl")
|
||||
.HasMaxLength(2083);
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(254);
|
||||
|
||||
b.Property<string>("ForumUrl")
|
||||
.HasMaxLength(2083);
|
||||
|
||||
b.Property<string>("HomeUrl")
|
||||
.HasMaxLength(2083);
|
||||
|
||||
b.Property<string>("IssuesUrl")
|
||||
.HasMaxLength(2083);
|
||||
|
||||
b.Property<DateTime>("ModifiedDateUtc")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(64);
|
||||
|
||||
b.Property<string>("ViewUrl")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2083);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("List");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace FilterLists.Data.Migrations
|
||||
{
|
||||
public partial class SetDefaultDateValue : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
//https://code.msdn.microsoft.com/Generic-Repository-Pattern-f133bca4/sourcecode?fileId=164016&pathId=1938870460
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
|
@ -14,10 +15,13 @@ public abstract class BaseEntity
|
|||
|
||||
[Required]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
//TODO: Implement http://stackoverflow.com/a/38102266/2343739 so DefaultValue takes effect in db automatically
|
||||
[DefaultValue("CURRENT_TIMESTAMP")]
|
||||
public DateTime AddedDateUtc { get; set; }
|
||||
|
||||
[Required]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
[DefaultValue("CURRENT_TIMESTAMP")]
|
||||
public DateTime ModifiedDateUtc { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue