diff --git a/EF_Code_First.sln b/EF_Code_First.sln
new file mode 100644
index 0000000..ecb78c4
--- /dev/null
+++ b/EF_Code_First.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32210.238
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EF_Code_First", "EF_Code_First\EF_Code_First.csproj", "{FFBBD235-ECBD-4D08-BA8D-DA902622CA7F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FFBBD235-ECBD-4D08-BA8D-DA902622CA7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FFBBD235-ECBD-4D08-BA8D-DA902622CA7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FFBBD235-ECBD-4D08-BA8D-DA902622CA7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FFBBD235-ECBD-4D08-BA8D-DA902622CA7F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {BFDEE537-EF31-4DDF-93C3-98B5DD3FFCFF}
+ EndGlobalSection
+EndGlobal
diff --git a/EF_Code_First/EF_Code_First.csproj b/EF_Code_First/EF_Code_First.csproj
new file mode 100644
index 0000000..d571ca5
--- /dev/null
+++ b/EF_Code_First/EF_Code_First.csproj
@@ -0,0 +1,34 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
diff --git a/EF_Code_First/Migrations/20220312173822_V0.0.Designer.cs b/EF_Code_First/Migrations/20220312173822_V0.0.Designer.cs
new file mode 100644
index 0000000..fee9ed6
--- /dev/null
+++ b/EF_Code_First/Migrations/20220312173822_V0.0.Designer.cs
@@ -0,0 +1,86 @@
+//
+using System;
+using EF_Code_First.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ [DbContext(typeof(SC_DbContext))]
+ [Migration("20220312173822_V0.0")]
+ partial class V00
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.3");
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Property("GradeId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("GradeName")
+ .HasColumnType("TEXT");
+
+ b.Property("Section")
+ .HasColumnType("TEXT");
+
+ b.HasKey("GradeId");
+
+ b.ToTable("Grade", (string)null);
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.Property("StudentId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("DateOfBirth")
+ .HasColumnType("TEXT");
+
+ b.Property("GradeId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Height")
+ .HasColumnType("TEXT");
+
+ b.Property("Photo")
+ .HasColumnType("BLOB");
+
+ b.Property("StudentName")
+ .HasColumnType("TEXT");
+
+ b.Property("Weight")
+ .HasColumnType("REAL");
+
+ b.HasKey("StudentId");
+
+ b.HasIndex("GradeId");
+
+ b.ToTable("Students", (string)null);
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.HasOne("EF_Code_First.Models.Grade", "Grade")
+ .WithMany("Students")
+ .HasForeignKey("GradeId");
+
+ b.Navigation("Grade");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Navigation("Students");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/20220312173822_V0.0.cs b/EF_Code_First/Migrations/20220312173822_V0.0.cs
new file mode 100644
index 0000000..16b37cf
--- /dev/null
+++ b/EF_Code_First/Migrations/20220312173822_V0.0.cs
@@ -0,0 +1,64 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ public partial class V00 : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Grade",
+ columns: table => new
+ {
+ GradeId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ GradeName = table.Column(type: "TEXT", nullable: true),
+ Section = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Grade", x => x.GradeId);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Students",
+ columns: table => new
+ {
+ StudentId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ StudentName = table.Column(type: "TEXT", nullable: true),
+ DateOfBirth = table.Column(type: "TEXT", nullable: true),
+ Photo = table.Column(type: "BLOB", nullable: true),
+ Height = table.Column(type: "TEXT", nullable: true),
+ Weight = table.Column(type: "REAL", nullable: true),
+ GradeId = table.Column(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Students", x => x.StudentId);
+ table.ForeignKey(
+ name: "FK_Students_Grade_GradeId",
+ column: x => x.GradeId,
+ principalTable: "Grade",
+ principalColumn: "GradeId");
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Students_GradeId",
+ table: "Students",
+ column: "GradeId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Students");
+
+ migrationBuilder.DropTable(
+ name: "Grade");
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/20220313151637_V0.2.Designer.cs b/EF_Code_First/Migrations/20220313151637_V0.2.Designer.cs
new file mode 100644
index 0000000..edb42be
--- /dev/null
+++ b/EF_Code_First/Migrations/20220313151637_V0.2.Designer.cs
@@ -0,0 +1,88 @@
+//
+using System;
+using EF_Code_First.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ [DbContext(typeof(SC_DbContext))]
+ [Migration("20220313151637_V0.2")]
+ partial class V02
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.3");
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Property("GradeId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("GradeName")
+ .HasColumnType("TEXT");
+
+ b.Property("Section")
+ .HasColumnType("TEXT");
+
+ b.HasKey("GradeId");
+
+ b.ToTable("Grades");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.Property("StudentId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("DateOfBirth")
+ .HasColumnType("TEXT");
+
+ b.Property("GradeId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Height")
+ .HasColumnType("TEXT");
+
+ b.Property("Photo")
+ .HasColumnType("BLOB");
+
+ b.Property("StudentName")
+ .HasColumnType("TEXT");
+
+ b.Property("Weight")
+ .HasColumnType("REAL");
+
+ b.HasKey("StudentId");
+
+ b.HasIndex("GradeId");
+
+ b.ToTable("Students");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.HasOne("EF_Code_First.Models.Grade", "Grade")
+ .WithMany("Students")
+ .HasForeignKey("GradeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Grade");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Navigation("Students");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/20220313151637_V0.2.cs b/EF_Code_First/Migrations/20220313151637_V0.2.cs
new file mode 100644
index 0000000..d3f505f
--- /dev/null
+++ b/EF_Code_First/Migrations/20220313151637_V0.2.cs
@@ -0,0 +1,64 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ public partial class V02 : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Students_Grade_GradeId",
+ table: "Students");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_Grade",
+ table: "Grade");
+
+ migrationBuilder.RenameTable(
+ name: "Grade",
+ newName: "Grades");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_Grades",
+ table: "Grades",
+ column: "GradeId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Students_Grades_GradeId",
+ table: "Students",
+ column: "GradeId",
+ principalTable: "Grades",
+ principalColumn: "GradeId",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Students_Grades_GradeId",
+ table: "Students");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_Grades",
+ table: "Grades");
+
+ migrationBuilder.RenameTable(
+ name: "Grades",
+ newName: "Grade");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_Grade",
+ table: "Grade",
+ column: "GradeId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Students_Grade_GradeId",
+ table: "Students",
+ column: "GradeId",
+ principalTable: "Grade",
+ principalColumn: "GradeId");
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/20220313154925_V0.3.Designer.cs b/EF_Code_First/Migrations/20220313154925_V0.3.Designer.cs
new file mode 100644
index 0000000..52f3267
--- /dev/null
+++ b/EF_Code_First/Migrations/20220313154925_V0.3.Designer.cs
@@ -0,0 +1,93 @@
+//
+using System;
+using EF_Code_First.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ [DbContext(typeof(SC_DbContext))]
+ [Migration("20220313154925_V0.3")]
+ partial class V03
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.3");
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Property("GradeId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("GradeName")
+ .HasColumnType("TEXT");
+
+ b.Property("Section")
+ .HasColumnType("TEXT");
+
+ b.HasKey("GradeId");
+
+ b.ToTable("Grades");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.Property("StudentId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DateOfBirth")
+ .HasColumnType("TEXT");
+
+ b.Property("G_Id")
+ .HasColumnType("INTEGER");
+
+ b.Property("Height")
+ .HasColumnType("TEXT");
+
+ b.Property("Photo")
+ .HasColumnType("BLOB");
+
+ b.Property("StudentName")
+ .HasColumnType("TEXT");
+
+ b.Property("Weight")
+ .HasColumnType("REAL");
+
+ b.HasKey("StudentId");
+
+ b.HasIndex("G_Id");
+
+ b.ToTable("Students");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.HasOne("EF_Code_First.Models.Grade", "Grade")
+ .WithMany()
+ .HasForeignKey("G_Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("EF_Code_First.Models.Grade", null)
+ .WithMany("Students")
+ .HasForeignKey("StudentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Grade");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Navigation("Students");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/20220313154925_V0.3.cs b/EF_Code_First/Migrations/20220313154925_V0.3.cs
new file mode 100644
index 0000000..8c5fb42
--- /dev/null
+++ b/EF_Code_First/Migrations/20220313154925_V0.3.cs
@@ -0,0 +1,89 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ public partial class V03 : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Students_Grades_GradeId",
+ table: "Students");
+
+ migrationBuilder.RenameColumn(
+ name: "GradeId",
+ table: "Students",
+ newName: "G_Id");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Students_GradeId",
+ table: "Students",
+ newName: "IX_Students_G_Id");
+
+ migrationBuilder.AlterColumn(
+ name: "StudentId",
+ table: "Students",
+ type: "INTEGER",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldType: "INTEGER")
+ .OldAnnotation("Sqlite:Autoincrement", true);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Students_Grades_G_Id",
+ table: "Students",
+ column: "G_Id",
+ principalTable: "Grades",
+ principalColumn: "GradeId",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Students_Grades_StudentId",
+ table: "Students",
+ column: "StudentId",
+ principalTable: "Grades",
+ principalColumn: "GradeId",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Students_Grades_G_Id",
+ table: "Students");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Students_Grades_StudentId",
+ table: "Students");
+
+ migrationBuilder.RenameColumn(
+ name: "G_Id",
+ table: "Students",
+ newName: "GradeId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Students_G_Id",
+ table: "Students",
+ newName: "IX_Students_GradeId");
+
+ migrationBuilder.AlterColumn(
+ name: "StudentId",
+ table: "Students",
+ type: "INTEGER",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldType: "INTEGER")
+ .Annotation("Sqlite:Autoincrement", true);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Students_Grades_GradeId",
+ table: "Students",
+ column: "GradeId",
+ principalTable: "Grades",
+ principalColumn: "GradeId",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}
diff --git a/EF_Code_First/Migrations/SC_DbContextModelSnapshot.cs b/EF_Code_First/Migrations/SC_DbContextModelSnapshot.cs
new file mode 100644
index 0000000..6f9d2cd
--- /dev/null
+++ b/EF_Code_First/Migrations/SC_DbContextModelSnapshot.cs
@@ -0,0 +1,91 @@
+//
+using System;
+using EF_Code_First.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EF_Code_First.Migrations
+{
+ [DbContext(typeof(SC_DbContext))]
+ partial class SC_DbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.3");
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Property("GradeId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("GradeName")
+ .HasColumnType("TEXT");
+
+ b.Property("Section")
+ .HasColumnType("TEXT");
+
+ b.HasKey("GradeId");
+
+ b.ToTable("Grades");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.Property("StudentId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DateOfBirth")
+ .HasColumnType("TEXT");
+
+ b.Property("G_Id")
+ .HasColumnType("INTEGER");
+
+ b.Property("Height")
+ .HasColumnType("TEXT");
+
+ b.Property("Photo")
+ .HasColumnType("BLOB");
+
+ b.Property("StudentName")
+ .HasColumnType("TEXT");
+
+ b.Property("Weight")
+ .HasColumnType("REAL");
+
+ b.HasKey("StudentId");
+
+ b.HasIndex("G_Id");
+
+ b.ToTable("Students");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Student", b =>
+ {
+ b.HasOne("EF_Code_First.Models.Grade", "Grade")
+ .WithMany()
+ .HasForeignKey("G_Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("EF_Code_First.Models.Grade", null)
+ .WithMany("Students")
+ .HasForeignKey("StudentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Grade");
+ });
+
+ modelBuilder.Entity("EF_Code_First.Models.Grade", b =>
+ {
+ b.Navigation("Students");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EF_Code_First/Models/Grade.cs b/EF_Code_First/Models/Grade.cs
new file mode 100644
index 0000000..d225898
--- /dev/null
+++ b/EF_Code_First/Models/Grade.cs
@@ -0,0 +1,13 @@
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace EF_Code_First.Models
+{
+ public class Grade
+ {
+ public int GradeId { get; set; }
+ public string? GradeName { get; set; }
+ public string? Section { get; set; }
+ [ForeignKey ("StudentId")]
+ public ICollection? Students { get; set; }
+ }
+}
diff --git a/EF_Code_First/Models/SC_DbContext.cs b/EF_Code_First/Models/SC_DbContext.cs
new file mode 100644
index 0000000..4c6fe3b
--- /dev/null
+++ b/EF_Code_First/Models/SC_DbContext.cs
@@ -0,0 +1,34 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace EF_Code_First.Models
+{
+ public class SC_DbContext : DbContext
+ {
+ public string DbPath { get; }
+ public DbSet Students { get; set; }
+ public DbSet Grades { get; set; }
+
+ public SC_DbContext() : base()
+ {
+ var folder = Environment.SpecialFolder.LocalApplicationData;
+ var path = Environment.GetFolderPath(folder);
+ DbPath = Path.Join(path, "student.db");
+ }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ => options.UseSqlite($"Data Source={DbPath}");
+ /*
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity().HasOne(g => g.Grade)
+ .WithMany(s => s.Students)
+ .IsRequired(true);
+ modelBuilder.Entity().ToTable("Students");
+ modelBuilder.Entity().HasMany(s => s.Students)
+ .WithOne(s => s.Grade)
+ .IsRequired(false);
+ modelBuilder.Entity().ToTable("Grade");
+ }
+ */
+ }
+}
diff --git a/EF_Code_First/Models/Student.cs b/EF_Code_First/Models/Student.cs
new file mode 100644
index 0000000..53ef1c6
--- /dev/null
+++ b/EF_Code_First/Models/Student.cs
@@ -0,0 +1,36 @@
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Text;
+
+namespace EF_Code_First.Models
+{
+ public class Student
+ {
+ public int StudentId { get; set; }
+ public string? StudentName { get; set; }
+ public DateTime? DateOfBirth { get; set; }
+ public byte[]? Photo { get; set; }
+ public decimal? Height { get; set; }
+ public float? Weight { get; set; }
+ [ForeignKey ("Grade")]
+ public int G_Id { get; set; }
+ //Navigation Property
+ public Grade Grade { get; set; }
+
+
+ public override string ToString()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ builder.Append(StudentId);
+ builder.Append(" :");
+ builder.Append(StudentName);
+ builder.Append(" :");
+ builder.Append(DateOfBirth);
+ builder.Append(" :");
+ builder.Append(Weight);
+ builder.Append(" :");
+ builder.Append(Height);
+ return builder.ToString();
+ }
+ }
+}
diff --git a/EF_Code_First/Program.cs b/EF_Code_First/Program.cs
new file mode 100644
index 0000000..8d92093
--- /dev/null
+++ b/EF_Code_First/Program.cs
@@ -0,0 +1,68 @@
+using System.Text;
+using EF_Code_First.Models;
+using System.Linq;
+using Microsoft.EntityFrameworkCore;
+
+namespace EF_Code_First
+{
+ public class Program
+ {
+ static void Main(string[] args)
+ {
+ using (var ctx = new SC_DbContext())
+ {
+ /*
+ var grade = ctx.Grades.Single(g => g.GradeId == 5);
+
+
+ var stud = new Student()
+ {
+ StudentName = "Michael Maier",
+ Weight = (float?)102,
+ Height = (decimal?)175,
+ DateOfBirth = DateTime.Parse("1970-10-11"),
+ Grade = grade
+ };
+ Console.WriteLine($"new Student: {stud}");
+ ctx.Students.Add(stud);
+ ctx.SaveChanges();
+ */
+ List grades = ctx.Grades
+ .Include(st=> st.Students)
+ .ToList();
+
+ List students = ctx.Students
+ .Include(g=> g.Grade)
+ .ToList();
+
+ foreach (var s in students)
+ {
+
+ //Console.WriteLine(s.Grade.ToString);
+
+ //var currentgrade = ctx.Grades.Single(g => g.GradeId == s.G_Id);
+ //Console.WriteLine($"Grade = {currentgrade.ToString} ");
+ StringBuilder b = new StringBuilder();
+ b.Append(s.StudentName);
+ b.Append(": ");
+ b.Append(s.Weight);
+ b.Append(": ");
+ b.Append(s.Height);
+ b.Append(": ");
+ b.Append(s.DateOfBirth);
+ b.Append(": ");
+ b.Append(s.Grade.GradeName);
+ b.Append(": ");
+ b.Append(s.Grade.Section);
+ Console.WriteLine(b.ToString());
+
+ }
+
+ Console.WriteLine (ctx.DbPath);
+
+
+
+ }
+ }
+ }
+}
diff --git a/EF_Code_First/Properties/Resources.Designer.cs b/EF_Code_First/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..dafcd42
--- /dev/null
+++ b/EF_Code_First/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace EF_Code_First.Properties {
+ using System;
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
+ // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EF_Code_First.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/EF_Code_First/Properties/Resources.resx b/EF_Code_First/Properties/Resources.resx
new file mode 100644
index 0000000..4fdb1b6
--- /dev/null
+++ b/EF_Code_First/Properties/Resources.resx
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/EF_Code_First/SC_DbContext.dgml b/EF_Code_First/SC_DbContext.dgml
new file mode 100644
index 0000000..dc7d85e
--- /dev/null
+++ b/EF_Code_First/SC_DbContext.dgml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file