-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from TechLiam/v1.2.0
Add async methods and logging (#12)
- Loading branch information
Showing
30 changed files
with
1,608 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Examples/WithDatabase/Migrations/20191014133519_AddedUserData.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
Examples/WithDatabase/Migrations/20191014133519_AddedUserData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
Examples/WithDatabase/Migrations/20191015093118_AddedRolesForUsers.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Examples/WithDatabase/Migrations/20191015093118_AddedRolesForUsers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
79
Examples/WithDatabase/Migrations/DatabaseContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
Oops, something went wrong.