Nick Rirush
5 years ago
11 changed files with 197 additions and 5 deletions
@ -0,0 +1,49 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
using QuickCHAT.Models; |
|||
|
|||
namespace QuickCHAT.Migrations |
|||
{ |
|||
[DbContext(typeof(DatabaseContext))] |
|||
[Migration("20190205093645_CreateUsers")] |
|||
partial class CreateUsers |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
|||
.HasAnnotation("ProductVersion", "2.2.1-servicing-10028") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|||
|
|||
modelBuilder.Entity("QuickCHAT.Models.User", b => |
|||
{ |
|||
b.Property<int>("UserID") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Description"); |
|||
|
|||
b.Property<string>("First"); |
|||
|
|||
b.Property<string>("Last"); |
|||
|
|||
b.Property<string>("Password"); |
|||
|
|||
b.Property<string>("Username") |
|||
.IsRequired(); |
|||
|
|||
b.HasKey("UserID"); |
|||
|
|||
b.HasAlternateKey("Username") |
|||
.HasName("AK_Username"); |
|||
|
|||
b.ToTable("Users"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
|
|||
namespace QuickCHAT.Migrations |
|||
{ |
|||
public partial class CreateUsers : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "Users", |
|||
columns: table => new |
|||
{ |
|||
UserID = table.Column<int>(nullable: false) |
|||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), |
|||
Username = table.Column<string>(nullable: false), |
|||
Password = table.Column<string>(nullable: true), |
|||
First = table.Column<string>(nullable: true), |
|||
Last = table.Column<string>(nullable: true), |
|||
Description = table.Column<string>(nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Users", x => x.UserID); |
|||
table.UniqueConstraint("AK_Username", x => x.Username); |
|||
}); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "Users"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
using QuickCHAT.Models; |
|||
|
|||
namespace QuickCHAT.Migrations |
|||
{ |
|||
[DbContext(typeof(DatabaseContext))] |
|||
partial class DatabaseContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) |
|||
.HasAnnotation("ProductVersion", "2.2.1-servicing-10028") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|||
|
|||
modelBuilder.Entity("QuickCHAT.Models.User", b => |
|||
{ |
|||
b.Property<int>("UserID") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Description"); |
|||
|
|||
b.Property<string>("First"); |
|||
|
|||
b.Property<string>("Last"); |
|||
|
|||
b.Property<string>("Password"); |
|||
|
|||
b.Property<string>("Username") |
|||
.IsRequired(); |
|||
|
|||
b.HasKey("UserID"); |
|||
|
|||
b.HasAlternateKey("Username") |
|||
.HasName("AK_Username"); |
|||
|
|||
b.ToTable("Users"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,2 @@ |
|||
@page |
|||
<h1>Hello, World!</h1> |
@ -0,0 +1,7 @@ |
|||
<!DOCTYPE html> |
|||
<head> |
|||
<title>@ViewData["Title"] - QuickCHAT</title> |
|||
</head> |
|||
<body> |
|||
@RenderBody() |
|||
</body> |
@ -0,0 +1,3 @@ |
|||
@{ |
|||
Layout = "_Layout"; |
|||
} |
@ -0,0 +1,30 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Configuration; |
|||
|
|||
namespace QuickCHAT.Models { |
|||
public class DatabaseContext : DbContext { |
|||
public DbSet<User> Users { get; set; } |
|||
|
|||
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) |
|||
{} |
|||
|
|||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) { |
|||
modelBuilder.Entity<User>() |
|||
.HasAlternateKey(u => u.Username) |
|||
.HasName("AK_Username"); |
|||
} |
|||
} |
|||
|
|||
public class User { |
|||
public int UserID { get; set; } |
|||
public string Username { get; set; } |
|||
public string Password { get; set; } |
|||
public string First { get; set; } |
|||
public string Last { get; set; } |
|||
public string Description { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue