Skip to content

Commit

Permalink
Added support for Guid.
Browse files Browse the repository at this point in the history
Added DateTime and Guid fileds in example projects.
Added migrations in example projects.
  • Loading branch information
omaxel committed Sep 14, 2017
1 parent 3fcf25f commit c217e05
Show file tree
Hide file tree
Showing 24 changed files with 651 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
private void Init()
{
Database.EnsureCreated();

if (People.CountAsync().Result == 0)
{
People.AddRange(
new Person() { Name = "Name 1", Surname = "Surname 1", Age = 21 },
new Person() { Name = "Name 2", Surname = "Surname 2", Age = 22 },
new Person() { Name = "Name 3", Surname = "Surname 3", Age = 23 },
new Person() { Name = "Name 4", Surname = "Surname 4", Age = 24 },
new Person() { Name = "Name 5", Surname = "Surname 5", Age = 25 },
new Person() { Name = "Name 6", Surname = "Surname 6", Age = 26 },
new Person() { Name = "Name 7", Surname = "Surname 7", Age = 27 },
new Person() { Name = "Name 8", Surname = "Surname 8", Age = 28 },
new Person() { Name = "Name 9", Surname = "Surname 9", Age = 29 }
);
SaveChanges();
}
}


Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;

namespace SimplePatch.Examples.Core.DAL.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "People",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Age = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: false),
Surname = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_People", x => x.Id);
});
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "People");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

namespace SimplePatch.Examples.Core.DAL.Migrations
{
public partial class BirthDate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "BirthDate",
table: "People",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BirthDate",
table: "People");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

namespace SimplePatch.Examples.Core.DAL.Migrations
{
public partial class GlobalId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "GlobalId",
table: "People",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "GlobalId",
table: "People");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using SimplePatch.Examples.Core.DAL;

namespace SimplePatch.Examples.Core.DAL.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

modelBuilder.Entity("SimplePatch.Examples.Core.DAL.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();

b.Property<int>("Age");

b.Property<DateTime?>("BirthDate");

b.Property<Guid?>("GlobalId");

b.Property<string>("Name")
.IsRequired();

b.Property<string>("Surname")
.IsRequired();

b.HasKey("Id");

b.ToTable("People");
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SimplePatch.Examples.Core.DAL
Expand All @@ -15,5 +16,9 @@ public class Person
public string Surname { get; set; }

public int Age { get; set; }

public DateTime? BirthDate { get; set; }

public Guid? GlobalId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="SimplePatch" Version="1.2.0" />
<PackageReference Include="SimplePatch" Version="1.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SimplePatch.Examples.FullNET.DAL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class BirthDate : DbMigration
{
public override void Up()
{
AddColumn("dbo.People", "BirthDate", c => c.DateTime());
}

public override void Down()
{
DropColumn("dbo.People", "BirthDate");
}
}
}
Loading

0 comments on commit c217e05

Please sign in to comment.