From 2ea88d97e1c205f4ba68902f903fde12c01da891 Mon Sep 17 00:00:00 2001 From: ReiMerc Date: Thu, 9 Nov 2023 23:48:49 +0100 Subject: [PATCH] Initial commit --- .gitignore | 4 +++ Migrations/20231109224704_Init.Designer.cs | 41 ++++++++++++++++++++++ Migrations/20231109224704_Init.cs | 35 ++++++++++++++++++ Migrations/GamerContextModelSnapshot.cs | 38 ++++++++++++++++++++ Program.cs | 38 ++++++++++++++++++++ h3.csproj | 19 ++++++++++ 6 files changed, 175 insertions(+) create mode 100644 .gitignore create mode 100644 Migrations/20231109224704_Init.Designer.cs create mode 100644 Migrations/20231109224704_Init.cs create mode 100644 Migrations/GamerContextModelSnapshot.cs create mode 100644 Program.cs create mode 100644 h3.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c0aab9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +obj/ +db.sqlite3 + diff --git a/Migrations/20231109224704_Init.Designer.cs b/Migrations/20231109224704_Init.Designer.cs new file mode 100644 index 0000000..057f750 --- /dev/null +++ b/Migrations/20231109224704_Init.Designer.cs @@ -0,0 +1,41 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace h3.Migrations +{ + [DbContext(typeof(GamerContext))] + [Migration("20231109224704_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.13"); + + modelBuilder.Entity("Person", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Age") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("People"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20231109224704_Init.cs b/Migrations/20231109224704_Init.cs new file mode 100644 index 0000000..ec6e364 --- /dev/null +++ b/Migrations/20231109224704_Init.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace h3.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "People", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Age = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_People", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "People"); + } + } +} diff --git a/Migrations/GamerContextModelSnapshot.cs b/Migrations/GamerContextModelSnapshot.cs new file mode 100644 index 0000000..2651792 --- /dev/null +++ b/Migrations/GamerContextModelSnapshot.cs @@ -0,0 +1,38 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace h3.Migrations +{ + [DbContext(typeof(GamerContext))] + partial class GamerContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.13"); + + modelBuilder.Entity("Person", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Age") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("People"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..240d138 --- /dev/null +++ b/Program.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +public class GamerContext : DbContext +{ + public DbSet People { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + { + options.UseSqlite("DataSource=db.sqlite3"); + } +} + +public class Person +{ + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + public string Name { get; set; } + public int Age { get; set; } +} + +public class Program +{ + public static void Main() + { + Console.WriteLine("hi"); + + var context = new GamerContext(); + + context.Add(new Person { Name = "John", Age = 30 }); + context.SaveChanges(); + } +} + diff --git a/h3.csproj b/h3.csproj new file mode 100644 index 0000000..6a9688a --- /dev/null +++ b/h3.csproj @@ -0,0 +1,19 @@ + + + + Exe + net7.0 + enable + enable + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + +