SES-65 #5
@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SessionCompanion.Database.Tables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database
|
||||||
|
{
|
||||||
|
public class ApplicationDbContext : DbContext
|
||||||
|
{
|
||||||
|
public virtual DbSet<Alignment> Alignments { get; set; }
|
||||||
|
public virtual DbSet<Background> Backgrounds { get; set; }
|
||||||
|
public virtual DbSet<Biography> Biographies { get; set; }
|
||||||
|
public virtual DbSet<Character> Characters { get; set; }
|
||||||
|
public virtual DbSet<Class> Classes { get; set; }
|
||||||
|
public virtual DbSet<Race> Races { get; set; }
|
||||||
|
public virtual DbSet<Statistics> Statistics { get; set; }
|
||||||
|
public virtual DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(builder);
|
||||||
|
builder.Entity<User>().HasData(SeedData.SeedUsers());
|
||||||
s426135 marked this conversation as resolved
Outdated
|
|||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
317
SessionCompanion/SessionCompanion.Database/Migrations/20201203161115_Base-Tables.Designer.cs
generated
Normal file
317
SessionCompanion/SessionCompanion.Database/Migrations/20201203161115_Base-Tables.Designer.cs
generated
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SessionCompanion.Database;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
[Migration("20201203161115_Base-Tables")]
|
||||||
|
partial class BaseTables
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.UseIdentityColumns()
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.0");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Alignments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Backgrounds");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("AlignmentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("BackgroundId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CharacterId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ClassId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("RaceId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Sex")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AlignmentId");
|
||||||
|
|
||||||
|
b.HasIndex("BackgroundId");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ClassId");
|
||||||
|
|
||||||
|
b.HasIndex("RaceId");
|
||||||
|
|
||||||
|
b.ToTable("Biographies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Characters");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Classes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Races");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("ArmorClass")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CharacterId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CurrentHealthPoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ExperiencePoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("HealthPoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Initiative")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Level")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Proficiency")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Speed")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Statistics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Nickname")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Nickname = "Morwiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Nickname = "Cichoklepiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Nickname = "Ruletka",
|
||||||
|
Password = "123"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("AlignmentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("BackgroundId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
|
||||||
|
.WithOne("Biography")
|
||||||
|
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("ClassId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("RaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Alignment");
|
||||||
|
|
||||||
|
b.Navigation("Background");
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
|
||||||
|
b.Navigation("Class");
|
||||||
|
|
||||||
|
b.Navigation("Race");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.User", "User")
|
||||||
|
.WithMany("Character")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
|
||||||
|
.WithOne("Statistics")
|
||||||
|
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
|
||||||
|
b.Navigation("Statistics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Character");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,248 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class BaseTables : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Alignments",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Alignments", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Backgrounds",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Backgrounds", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Classes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Classes", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Races",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Races", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Users",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Nickname = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Users", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Characters",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
UserId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Characters", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Characters_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Biographies",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
CharacterId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||||
|
ClassId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
RaceId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
AlignmentId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
BackgroundId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Sex = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Biographies", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Biographies_Alignments_AlignmentId",
|
||||||
|
column: x => x.AlignmentId,
|
||||||
|
principalTable: "Alignments",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Biographies_Backgrounds_BackgroundId",
|
||||||
|
column: x => x.BackgroundId,
|
||||||
|
principalTable: "Backgrounds",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Biographies_Characters_CharacterId",
|
||||||
|
column: x => x.CharacterId,
|
||||||
|
principalTable: "Characters",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Biographies_Classes_ClassId",
|
||||||
|
column: x => x.ClassId,
|
||||||
|
principalTable: "Classes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Biographies_Races_RaceId",
|
||||||
|
column: x => x.RaceId,
|
||||||
|
principalTable: "Races",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Statistics",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
CharacterId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ExperiencePoints = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Level = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Speed = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Initiative = table.Column<int>(type: "int", nullable: false),
|
||||||
|
HealthPoints = table.Column<int>(type: "int", nullable: false),
|
||||||
|
CurrentHealthPoints = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ArmorClass = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Proficiency = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Statistics", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Statistics_Characters_CharacterId",
|
||||||
|
column: x => x.CharacterId,
|
||||||
|
principalTable: "Characters",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "Users",
|
||||||
|
columns: new[] { "Id", "Nickname", "Password" },
|
||||||
|
values: new object[] { 1, "Morwiec", "123" });
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "Users",
|
||||||
|
columns: new[] { "Id", "Nickname", "Password" },
|
||||||
|
values: new object[] { 2, "Cichoklepiec", "123" });
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "Users",
|
||||||
|
columns: new[] { "Id", "Nickname", "Password" },
|
||||||
|
values: new object[] { 3, "Ruletka", "123" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Biographies_AlignmentId",
|
||||||
|
table: "Biographies",
|
||||||
|
column: "AlignmentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Biographies_BackgroundId",
|
||||||
|
table: "Biographies",
|
||||||
|
column: "BackgroundId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Biographies_CharacterId",
|
||||||
|
table: "Biographies",
|
||||||
|
column: "CharacterId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Biographies_ClassId",
|
||||||
|
table: "Biographies",
|
||||||
|
column: "ClassId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Biographies_RaceId",
|
||||||
|
table: "Biographies",
|
||||||
|
column: "RaceId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Characters_UserId",
|
||||||
|
table: "Characters",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Statistics_CharacterId",
|
||||||
|
table: "Statistics",
|
||||||
|
column: "CharacterId",
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Biographies");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Statistics");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Alignments");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Backgrounds");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Classes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Races");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Characters");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,315 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SessionCompanion.Database;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.UseIdentityColumns()
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.0");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Alignments");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Backgrounds");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("AlignmentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("BackgroundId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CharacterId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ClassId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("RaceId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Sex")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AlignmentId");
|
||||||
|
|
||||||
|
b.HasIndex("BackgroundId");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ClassId");
|
||||||
|
|
||||||
|
b.HasIndex("RaceId");
|
||||||
|
|
||||||
|
b.ToTable("Biographies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Characters");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Classes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Races");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<int>("ArmorClass")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CharacterId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("CurrentHealthPoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ExperiencePoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("HealthPoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Initiative")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Level")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Proficiency")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Speed")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Statistics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.UseIdentityColumn();
|
||||||
|
|
||||||
|
b.Property<string>("Nickname")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Nickname = "Morwiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Nickname = "Cichoklepiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Nickname = "Ruletka",
|
||||||
|
Password = "123"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("AlignmentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("BackgroundId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
|
||||||
|
.WithOne("Biography")
|
||||||
|
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("ClassId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
|
||||||
|
.WithMany("Biography")
|
||||||
|
.HasForeignKey("RaceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Alignment");
|
||||||
|
|
||||||
|
b.Navigation("Background");
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
|
||||||
|
b.Navigation("Class");
|
||||||
|
|
||||||
|
b.Navigation("Race");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.User", "User")
|
||||||
|
.WithMany("Character")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
|
||||||
|
.WithOne("Statistics")
|
||||||
|
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
|
||||||
|
b.Navigation("Statistics");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Biography");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Character");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
SessionCompanion/SessionCompanion.Database/SeedData.cs
Normal file
39
SessionCompanion/SessionCompanion.Database/SeedData.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SessionCompanion.Database.Tables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database
|
||||||
|
{
|
||||||
|
public class SeedData
|
||||||
|
{
|
||||||
|
static public List<User> SeedUsers()
|
||||||
|
{
|
||||||
|
List<User> users = new List<User>
|
||||||
|
{
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Nickname = "Morwiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Nickname = "Cichoklepiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Nickname = "Ruletka",
|
||||||
|
Password = "123"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Repositories\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Alignment : BaseEntity
|
||||||
|
{
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Background : BaseEntity
|
||||||
|
{
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Biography : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(Character))]
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
public virtual Character Character { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Class))]
|
||||||
|
public int ClassId { get; set; }
|
||||||
|
public virtual Class Class { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Race))]
|
||||||
|
public int RaceId { get; set; }
|
||||||
|
public virtual Race Race { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Alignment))]
|
||||||
|
public int AlignmentId { get; set; }
|
||||||
|
public virtual Alignment Alignment { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Background))]
|
||||||
|
public int BackgroundId { get; set; }
|
||||||
|
public virtual Background Background { get; set; }
|
||||||
|
|
||||||
|
public string Sex { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Character : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(User))]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
public virtual Biography Biography { get; set; }
|
||||||
|
public virtual Statistics Statistics { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
SessionCompanion/SessionCompanion.Database/Tables/Class.cs
Normal file
14
SessionCompanion/SessionCompanion.Database/Tables/Class.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Class : BaseEntity
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
//public int HitDie { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
SessionCompanion/SessionCompanion.Database/Tables/Race.cs
Normal file
12
SessionCompanion/SessionCompanion.Database/Tables/Race.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Race : BaseEntity
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Statistics : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(Character))]
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
public virtual Character Character { get; set; }
|
||||||
|
|
||||||
|
public int ExperiencePoints { get; set; }
|
||||||
|
public int Level { get; set; }
|
||||||
|
public int Speed { get; set; }
|
||||||
|
public int Initiative { get; set; }
|
||||||
|
public int HealthPoints { get; set; }
|
||||||
|
public int CurrentHealthPoints { get; set; }
|
||||||
|
public int ArmorClass { get; set; }
|
||||||
|
public int Proficiency { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
SessionCompanion/SessionCompanion.Database/Tables/User.cs
Normal file
13
SessionCompanion/SessionCompanion.Database/Tables/User.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class User : BaseEntity
|
||||||
|
{
|
||||||
|
public string Nickname { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public ICollection<Character> Character { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.30717.126
|
VisualStudioVersion = 16.0.30717.126
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion", "SessionCompanion\SessionCompanion.csproj", "{C646135F-16CE-4B16-B041-252D343D4E01}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion", "SessionCompanion\SessionCompanion.csproj", "{C646135F-16CE-4B16-B041-252D343D4E01}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion.Database", "SessionCompanion.Database\SessionCompanion.Database.csproj", "{CA05189B-A4AB-4946-80DC-EFA075A10F09}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -15,6 +17,10 @@ Global
|
|||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -27,6 +32,10 @@
|
|||||||
<Folder Include="Controllers\" />
|
<Folder Include="Controllers\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SessionCompanion.Database\SessionCompanion.Database.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
||||||
<!-- Ensure Node.js is installed -->
|
<!-- Ensure Node.js is installed -->
|
||||||
<Exec Command="node --version" ContinueOnError="true">
|
<Exec Command="node --version" ContinueOnError="true">
|
||||||
|
@ -2,9 +2,11 @@ using Microsoft.AspNetCore.Builder;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
using Microsoft.AspNetCore.HttpsPolicy;
|
||||||
using Microsoft.AspNetCore.SpaServices.AngularCli;
|
using Microsoft.AspNetCore.SpaServices.AngularCli;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using SessionCompanion.Database;
|
||||||
|
|
||||||
namespace SessionCompanion
|
namespace SessionCompanion
|
||||||
{
|
{
|
||||||
@ -22,16 +24,24 @@ namespace SessionCompanion
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddControllersWithViews();
|
services.AddControllersWithViews();
|
||||||
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
|
options.UseSqlServer(
|
||||||
|
Configuration.GetConnectionString("DefaultConnection")));
|
||||||
// In production, the Angular files will be served from this directory
|
// In production, the Angular files will be served from this directory
|
||||||
services.AddSpaStaticFiles(configuration =>
|
services.AddSpaStaticFiles(configuration =>
|
||||||
{
|
{
|
||||||
s426134
commented
Przenieś to linijkę wyżej. Po bazie będzie robiony swagger. Dopiero po Swaggerze mogą zostać dodane pliki statyczne. Inaczej mogłoby dojśc do sytuacj, że front nie otrzymałby pełnych informacji o swaggerze. Przenieś to linijkę wyżej. Po bazie będzie robiony swagger. Dopiero po Swaggerze mogą zostać dodane pliki statyczne. Inaczej mogłoby dojśc do sytuacj, że front nie otrzymałby pełnych informacji o swaggerze.
s426135
commented
Linijke wyżej czyli wewnątrz Linijke wyżej czyli wewnątrz
services.AddSpaStaticFiles(configuration =>
?
czy jeszcze przed tym?
s426134
commented
Przed Przed
|
|||||||
configuration.RootPath = "ClientApp/dist";
|
configuration.RootPath = "ClientApp/dist";
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s426135 marked this conversation as resolved
s426134
commented
Brakuje wywołania migracji Brakuje wywołania migracji
|
|||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
|
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||||
|
{
|
||||||
|
serviceScope.ServiceProvider.GetService<ApplicationDbContext>().Database.Migrate();
|
||||||
|
}
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=SessionCompanion;Trusted_Connection=True;MultipleActiveResultSets=true"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
Przenieśmy to do osobnych plików, bo zacznie ię niedługo robić syfek jak ostatnio.