Skip to content

Commit

Permalink
Merge pull request #13 from TechLiam/v1.2.0
Browse files Browse the repository at this point in the history
Add async methods and logging (#12)
  • Loading branch information
TechLiam authored Oct 15, 2019
2 parents 7e04f4c + 95213e6 commit 8d82640
Show file tree
Hide file tree
Showing 30 changed files with 1,608 additions and 82 deletions.
22 changes: 22 additions & 0 deletions Examples/WithDatabase/Database/DatabaseContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;

namespace WithDatabase.Database
{
public class DatabaseContext : DbContext
{

public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
{
}

public DbSet<SqrlUser> SqrlUser { get; set; }

public DbSet<User> User { get; set; }

public void UpdateDatabase()
{
this.Database.Migrate();
}

}
}
22 changes: 22 additions & 0 deletions Examples/WithDatabase/Database/SqrlUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WithDatabase.Database
{
public class SqrlUser
{

public int Id { get; set; }

public string UserId { get; set; }

public bool Locked { get; set; }

public string Suk { get; set; }

public string Vuk { get; set; }

}
}
22 changes: 22 additions & 0 deletions Examples/WithDatabase/Database/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WithDatabase.Database
{
public class User
{

public int Id { get; set; }

public string Username { get; set; }

public SqrlUser SqrlUser { get; set; }

public int SqrlUserId { get; set; }

public string Role { get; set; }

}
}

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

60 changes: 60 additions & 0 deletions Examples/WithDatabase/Migrations/20191014133519_AddedUserData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace WithDatabase.Migrations
{
public partial class AddedUserData : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SqrlUser",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(nullable: true),
Locked = table.Column<bool>(nullable: false),
Suk = table.Column<string>(nullable: true),
Vuk = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_SqrlUser", x => x.Id);
});

migrationBuilder.CreateTable(
name: "User",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Username = table.Column<string>(nullable: true),
SqrlUserId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
table.ForeignKey(
name: "FK_User_SqrlUser_SqrlUserId",
column: x => x.SqrlUserId,
principalTable: "SqrlUser",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_User_SqrlUserId",
table: "User",
column: "SqrlUserId");
}

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

migrationBuilder.DropTable(
name: "SqrlUser");
}
}
}

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,22 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace WithDatabase.Migrations
{
public partial class AddedRolesForUsers : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Role",
table: "User",
nullable: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Role",
table: "User");
}
}
}
79 changes: 79 additions & 0 deletions Examples/WithDatabase/Migrations/DatabaseContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WithDatabase.Database;

namespace WithDatabase.Migrations
{
[DbContext(typeof(DatabaseContext))]
partial class DatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

modelBuilder.Entity("WithDatabase.Database.SqrlUser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

b.Property<bool>("Locked")
.HasColumnType("bit");

b.Property<string>("Suk")
.HasColumnType("nvarchar(max)");

b.Property<string>("UserId")
.HasColumnType("nvarchar(max)");

b.Property<string>("Vuk")
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.ToTable("SqrlUser");
});

modelBuilder.Entity("WithDatabase.Database.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

b.Property<string>("Role")
.HasColumnType("nvarchar(max)");

b.Property<int>("SqrlUserId")
.HasColumnType("int");

b.Property<string>("Username")
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.HasIndex("SqrlUserId");

b.ToTable("User");
});

modelBuilder.Entity("WithDatabase.Database.User", b =>
{
b.HasOne("WithDatabase.Database.SqrlUser", "SqrlUser")
.WithMany()
.HasForeignKey("SqrlUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
Loading

0 comments on commit 8d82640

Please sign in to comment.