diff --git a/tp1/DbContextLib/DbContextLib.csproj b/tp1/DbContextLib/DbContextLib.csproj
new file mode 100644
index 0000000..f963c93
--- /dev/null
+++ b/tp1/DbContextLib/DbContextLib.csproj
@@ -0,0 +1,26 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
diff --git a/tp1/DbContextLib/LibraryContext.cs b/tp1/DbContextLib/LibraryContext.cs
new file mode 100644
index 0000000..1f8d92e
--- /dev/null
+++ b/tp1/DbContextLib/LibraryContext.cs
@@ -0,0 +1,21 @@
+using Microsoft.EntityFrameworkCore;
+using Entities;
+
+namespace DbContextLib
+{
+
+ public class LibraryContext: DbContext
+ {
+ public DbSet BooksSet{ get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseSqlite($"Data Source=tp1.Books.db");
+ }
+
+ }
+
+}
+
+
+
diff --git a/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.Designer.cs b/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.Designer.cs
new file mode 100644
index 0000000..69346df
--- /dev/null
+++ b/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.Designer.cs
@@ -0,0 +1,47 @@
+//
+using DbContextLib;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace DbContextLib.Migrations
+{
+ [DbContext(typeof(LibraryContext))]
+ [Migration("20240201082456_BooksMigration")]
+ partial class BooksMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
+
+ modelBuilder.Entity("Entities.BookEntity", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Author")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Isbn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("BooksSet");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.cs b/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.cs
new file mode 100644
index 0000000..2e153c8
--- /dev/null
+++ b/tp1/DbContextLib/Migrations/20240201082456_BooksMigration.cs
@@ -0,0 +1,36 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace DbContextLib.Migrations
+{
+ ///
+ public partial class BooksMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "BooksSet",
+ columns: table => new
+ {
+ ID = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Title = table.Column(type: "TEXT", nullable: false),
+ Author = table.Column(type: "TEXT", nullable: false),
+ Isbn = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BooksSet", x => x.ID);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "BooksSet");
+ }
+ }
+}
diff --git a/tp1/DbContextLib/Migrations/LibraryContextModelSnapshot.cs b/tp1/DbContextLib/Migrations/LibraryContextModelSnapshot.cs
new file mode 100644
index 0000000..61df967
--- /dev/null
+++ b/tp1/DbContextLib/Migrations/LibraryContextModelSnapshot.cs
@@ -0,0 +1,44 @@
+//
+using DbContextLib;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace DbContextLib.Migrations
+{
+ [DbContext(typeof(LibraryContext))]
+ partial class LibraryContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
+
+ modelBuilder.Entity("Entities.BookEntity", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Author")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Isbn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("BooksSet");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/tp1/DbContextLib/tp1.Books.db b/tp1/DbContextLib/tp1.Books.db
new file mode 100644
index 0000000..0ba5d30
Binary files /dev/null and b/tp1/DbContextLib/tp1.Books.db differ
diff --git a/tp1/Entities/BookEntity.cs b/tp1/Entities/BookEntity.cs
new file mode 100644
index 0000000..3cde984
--- /dev/null
+++ b/tp1/Entities/BookEntity.cs
@@ -0,0 +1,13 @@
+using System.Reflection;
+
+namespace Entities
+{
+ public class BookEntity
+ {
+
+ public int ID {get; set;}
+ public string Title { get; set; }
+ public string Author { get; set; }
+ public string Isbn { get; set; }
+ }
+}
diff --git a/tp1/Entities/Entities.csproj b/tp1/Entities/Entities.csproj
new file mode 100644
index 0000000..0c79874
--- /dev/null
+++ b/tp1/Entities/Entities.csproj
@@ -0,0 +1,22 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/tp1/Library/DbContextLib/LibraryContext.cs b/tp1/Library/DbContextLib/LibraryContext.cs
new file mode 100644
index 0000000..853f9cc
--- /dev/null
+++ b/tp1/Library/DbContextLib/LibraryContext.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using Library.Entities;
+
+
+namespace Library.DbContextLib
+{
+ public class LibraryContext : DbContext
+ {
+ public DbSet BooksSet { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseSqlite("Data Source=tp.Books.db");
+ }
+
+ }
+}
diff --git a/tp1/Library/Entities/BookEntity.cs b/tp1/Library/Entities/BookEntity.cs
new file mode 100644
index 0000000..4ecea42
--- /dev/null
+++ b/tp1/Library/Entities/BookEntity.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Library.Entities
+{
+ public class BookEntity
+ {
+ public int ID { get; set; }
+ public string Title { get; set; }
+ public string Author { get; set; }
+ public string Isbn { get; set; }
+
+ public BookEntity(string title, string author, string isbn) {
+ Title = title;
+ Author = author;
+ Isbn = isbn;
+ }
+ }
+}
diff --git a/tp1/Library/Library.csproj b/tp1/Library/Library.csproj
new file mode 100644
index 0000000..0c79874
--- /dev/null
+++ b/tp1/Library/Library.csproj
@@ -0,0 +1,22 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/tp1/Library/StubbedContextLib/StubbedContext.cs b/tp1/Library/StubbedContextLib/StubbedContext.cs
new file mode 100644
index 0000000..4474e2b
--- /dev/null
+++ b/tp1/Library/StubbedContextLib/StubbedContext.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Library.DbContextLib;
+using Library.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace Library.StubbedContextLib
+{
+ public class StubbedContext : DbContext
+ {
+ public List Books { get; set; }
+
+ public StubbedContext() {
+ Books.Add(new BookEntity("test", "test", "test"));
+ Books.Add(new BookEntity("test2", "test2", "test2"));
+ }
+
+ }
+}
diff --git a/tp1/Library/tp.Books.db b/tp1/Library/tp.Books.db
new file mode 100644
index 0000000..74136d8
Binary files /dev/null and b/tp1/Library/tp.Books.db differ
diff --git a/tp1/StubbedContextLib/StubbedContext.cs b/tp1/StubbedContextLib/StubbedContext.cs
new file mode 100644
index 0000000..b2e65bd
--- /dev/null
+++ b/tp1/StubbedContextLib/StubbedContext.cs
@@ -0,0 +1,11 @@
+using Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace StubbedContextLib
+{
+ public class StubbedContext : DbContext
+ {
+
+
+ }
+}
diff --git a/tp1/StubbedContextLib/StubbedContextLib.csproj b/tp1/StubbedContextLib/StubbedContextLib.csproj
new file mode 100644
index 0000000..e9bc770
--- /dev/null
+++ b/tp1/StubbedContextLib/StubbedContextLib.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
diff --git a/tp1/TestStub/BookEntity.cs b/tp1/TestStub/BookEntity.cs
new file mode 100644
index 0000000..a8bac3a
--- /dev/null
+++ b/tp1/TestStub/BookEntity.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TestStub
+{
+
+ public class BookEntity
+ {
+ public int ID { get; set; }
+ public string Title { get; set; }
+ public string Author { get; set; }
+ public string Isbn { get; set; }
+
+ public BookEntity(string title, string author, string isbn) {
+ Title = title;
+ Author = author;
+ Isbn = isbn;
+ }
+ }
+}
diff --git a/tp1/TestStub/LibraryContext.cs b/tp1/TestStub/LibraryContext.cs
new file mode 100644
index 0000000..450d9df
--- /dev/null
+++ b/tp1/TestStub/LibraryContext.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using Library.Entities;
+
+
+namespace TestStub
+{
+ public class LibraryContext : DbContext
+ {
+ public DbSet BooksSet { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseSqlite("Data Source=tp.Books.db");
+ }
+
+ }
+}
diff --git a/tp1/TestStub/Migrations/20240201143359_BooksMigrations.Designer.cs b/tp1/TestStub/Migrations/20240201143359_BooksMigrations.Designer.cs
new file mode 100644
index 0000000..c4db459
--- /dev/null
+++ b/tp1/TestStub/Migrations/20240201143359_BooksMigrations.Designer.cs
@@ -0,0 +1,47 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using TestStub;
+
+#nullable disable
+
+namespace TestStub.Migrations
+{
+ [DbContext(typeof(LibraryContext))]
+ [Migration("20240201143359_BooksMigrations")]
+ partial class BooksMigrations
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
+
+ modelBuilder.Entity("TestStub.BookEntity", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Author")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Isbn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("BooksSet");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/tp1/TestStub/Migrations/20240201143359_BooksMigrations.cs b/tp1/TestStub/Migrations/20240201143359_BooksMigrations.cs
new file mode 100644
index 0000000..1a50d42
--- /dev/null
+++ b/tp1/TestStub/Migrations/20240201143359_BooksMigrations.cs
@@ -0,0 +1,36 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace TestStub.Migrations
+{
+ ///
+ public partial class BooksMigrations : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "BooksSet",
+ columns: table => new
+ {
+ ID = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Title = table.Column(type: "TEXT", nullable: false),
+ Author = table.Column(type: "TEXT", nullable: false),
+ Isbn = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BooksSet", x => x.ID);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "BooksSet");
+ }
+ }
+}
diff --git a/tp1/TestStub/Migrations/LibraryContextModelSnapshot.cs b/tp1/TestStub/Migrations/LibraryContextModelSnapshot.cs
new file mode 100644
index 0000000..8c1c247
--- /dev/null
+++ b/tp1/TestStub/Migrations/LibraryContextModelSnapshot.cs
@@ -0,0 +1,44 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using TestStub;
+
+#nullable disable
+
+namespace TestStub.Migrations
+{
+ [DbContext(typeof(LibraryContext))]
+ partial class LibraryContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
+
+ modelBuilder.Entity("TestStub.BookEntity", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Author")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Isbn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("BooksSet");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/tp1/TestStub/Program.cs b/tp1/TestStub/Program.cs
new file mode 100644
index 0000000..7d494f6
--- /dev/null
+++ b/tp1/TestStub/Program.cs
@@ -0,0 +1,49 @@
+using TestStub;
+using Microsoft.Extensions.Options;
+
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
+
+using (var context = new LibraryContext())
+{
+ BookEntity chewie = new BookEntity("B3", "test1", "test1");
+ BookEntity yoda = new BookEntity ("B4", "test2", "test2");
+ BookEntity ewok = new BookEntity ("mistake", "test3", "test3");
+ BookEntity the100 = new BookEntity("the100", "test4", "test4");
+
+ context.BooksSet.Add(chewie);
+ context.BooksSet.Add(yoda);
+ context.BooksSet.Add(ewok);
+ context.BooksSet.Add(the100);
+
+ context.SaveChanges();
+}
+
+
+using (var context = new LibraryContext())
+{
+ foreach (var n in context.BooksSet)
+ {
+ Console.WriteLine($"Books: {n.ID} - {n.Title}");
+ }
+ context.SaveChanges();
+}
+
+
+using (var context = new LibraryContext())
+{
+ var eBooks = context.BooksSet.Where(b => b.Title.StartsWith("t")).First();
+ Console.WriteLine($"{eBooks.Title} (made by {eBooks.Author})");
+ eBooks.Title = "Border";
+ context.SaveChanges();
+}
+
+using (var context = new LibraryContext())
+{
+ Console.WriteLine("Deletes one item from de database");
+ var impostor = context.BooksSet
+ .SingleOrDefault(n => n.Title.Equals("mistake"));
+ context.Remove(impostor);
+ context.SaveChanges();
+
+}
\ No newline at end of file
diff --git a/tp1/TestStub/StubbedContext.cs b/tp1/TestStub/StubbedContext.cs
new file mode 100644
index 0000000..f397ada
--- /dev/null
+++ b/tp1/TestStub/StubbedContext.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Library.DbContextLib;
+using Library.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace TestStub
+{
+ public class StubbedContext : DbContext
+ {
+ public List Books { get; set; }
+
+ public StubbedContext() {
+ Books.Add(new BookEntity("test", "test", "test"));
+ Books.Add(new BookEntity("test2", "test2", "test2"));
+ }
+
+ }
+}
diff --git a/tp1/TestStub/TestStub.csproj b/tp1/TestStub/TestStub.csproj
new file mode 100644
index 0000000..546f891
--- /dev/null
+++ b/tp1/TestStub/TestStub.csproj
@@ -0,0 +1,28 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ $(MSBuildProjectDirectory)
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
diff --git a/tp1/TestStub/tp.Books.db b/tp1/TestStub/tp.Books.db
new file mode 100644
index 0000000..9b976f7
Binary files /dev/null and b/tp1/TestStub/tp.Books.db differ
diff --git a/tp1/tp1.sln b/tp1/tp1.sln
new file mode 100644
index 0000000..a0c64a8
--- /dev/null
+++ b/tp1/tp1.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34330.188
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestStub", "TestStub\TestStub.csproj", "{8960D74C-259D-4779-80B6-789BA257D2B2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{CDD5A87A-187A-4BC1-9E23-5559A2211B55}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8960D74C-259D-4779-80B6-789BA257D2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8960D74C-259D-4779-80B6-789BA257D2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8960D74C-259D-4779-80B6-789BA257D2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8960D74C-259D-4779-80B6-789BA257D2B2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CDD5A87A-187A-4BC1-9E23-5559A2211B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CDD5A87A-187A-4BC1-9E23-5559A2211B55}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CDD5A87A-187A-4BC1-9E23-5559A2211B55}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CDD5A87A-187A-4BC1-9E23-5559A2211B55}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {B2A30B02-81D8-43E5-9D54-25E8F801F280}
+ EndGlobalSection
+EndGlobal