Début Relation

Users et Images relier
Relation_EF
kekentin 1 month ago
parent 4d2047b03a
commit 6755e63274

@ -1 +1 @@

Console.WriteLine("bonjour");

@ -6,4 +6,22 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Entity\Entity.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;
using Microsoft.EntityFrameworkCore;
namespace Contextlib
{
public class WTFContext : DbContext
{
public DbSet<Images> Images { get; set; }
public DbSet<Users> Users { get; set; }
//public DbSet<Admin> Admin { get; set; }
public DbSet<Question> Question { get; set; }
public DbSet<Quiz> Quiz { get; set; }
//public DbSet<QuizQuestion> QuizQuestion { get; set; }
//public DbSet<RecordQuiz> RecordQuiz { get; set; }
public DbSet<Source> Source { get; set; }
public DbSet<Character> Character { get; set; }
public DbSet<Quote> Quote { get; set; }
//public DbSet<DailyQuote> DailyQuote { get; set; }
//public DbSet<Favorite> Favorite { get; set; }
//public DbSet<Commentary> Commentary { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=myFirstDatabase.mdf;Trusted_Connection=True;");
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Admin
{
//public int IdUsers { get; set; }
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Character
{
public int Id { get; set; }
public string Name { get; set; }
//public int IdImage { get; set; }
}
}

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Commentary
{
public int Id { get; set; }
//public int IdUsers { get; set; }
//public int IdQuote { get; set; }
public DateTime DateCommentary { get; set; }
public string Comment { get; set; }
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class DailyQuote
{
public int IdQuote { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Favorite
{
//public int IdUsers { get; set; }
//public int IdQuote { get; set; }
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Images
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string ImgPath { get; set; }
public ICollection<Users> Users { get; set; } = new List<Users>();
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public enum LangEnum
{
vo,
fr,
en
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Question
{
public int Id { get; set; }
public string Text { get; set; }
public string AnswerA { get; set; }
public string AnswerB { get; set; }
public string AnswerC { get; set; }
public string AnswerD { get; set; }
public string CorrectAnswer { get; set; }
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Quiz
{
public int Id { get; set; }
public string Title { get; set; }
//public int IdImage { get; set; }
public int NbQuestion { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class QuizQuestion
{
//public int IdQuiz { get; set; }
//public int IdQuestion { get; set; }
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Quote
{
public int Id { get; set; }
public string Content { get; set; }
public int Likes { get; set; }
public LangEnum Langage { get; set; }
public bool IsValid { get; set; }
//public int IdCharacter { get; set; }
//public int IdSource { get; set; }
//public int IdUsersPropose { get; set; }
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class RecordQuiz
{
public int IdUsers { get; set; }
public int IdQuiz { get; set; }
public int NbPoint { get; set; }
public int TimeQuiz { get; set; }
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Source
{
public int Id { get; set; }
public string Title { get; set; }
public int Year { get; set; }
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entity
{
public class Users
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string UserName { get; set; }
public string Email { get; set; }
public string Password { get; set; }
[ForeignKey(nameof(Images))]
public int IdImage { get; set; }
public Images Images { get; set; }
public DateTime Created { get; set; }
}
}

@ -26,3 +26,4 @@ namespace Shared
// 'quoteId' is the unique identifier of the quote to be removed from all users' favorites.
Task RemoveAllFavoriteForQuote(int quoteId);
}
}

@ -0,0 +1,205 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(StubWTFContext))]
[Migration("20250312160314_myFirstMigration")]
partial class myFirstMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entity.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Character");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImgPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("Entity.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerB")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerD")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrectAnswer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("Entity.Quiz", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("NbQuestion")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Quiz");
});
modelBuilder.Entity("Entity.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<int>("Langage")
.HasColumnType("int");
b.Property<int>("Likes")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Quote");
});
modelBuilder.Entity("Entity.Source", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Source");
});
modelBuilder.Entity("Entity.Users", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "dev@gmail.com",
Password = "1234",
UserName = "Dev"
});
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,149 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Character",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Character", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImgPath = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Question",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerA = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerB = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerC = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerD = table.Column<string>(type: "nvarchar(max)", nullable: false),
CorrectAnswer = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Question", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Quiz",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
NbQuestion = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quiz", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Quote",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
Likes = table.Column<int>(type: "int", nullable: false),
Langage = table.Column<int>(type: "int", nullable: false),
IsValid = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quote", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Source",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Year = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Source", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Created", "Email", "Password", "UserName" },
values: new object[] { 1, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "dev@gmail.com", "1234", "Dev" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Character");
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropTable(
name: "Question");
migrationBuilder.DropTable(
name: "Quiz");
migrationBuilder.DropTable(
name: "Quote");
migrationBuilder.DropTable(
name: "Source");
migrationBuilder.DropTable(
name: "Users");
}
}
}

@ -0,0 +1,248 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(StubWTFContext))]
[Migration("20250312162514_migr2")]
partial class migr2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entity.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Character");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImgPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Images");
b.HasData(
new
{
Id = 1,
ImgPath = "coucou"
},
new
{
Id = 2,
ImgPath = "bonjour"
});
});
modelBuilder.Entity("Entity.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerB")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerD")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrectAnswer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("Entity.Quiz", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("NbQuestion")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Quiz");
});
modelBuilder.Entity("Entity.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<int>("Langage")
.HasColumnType("int");
b.Property<int>("Likes")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Quote");
});
modelBuilder.Entity("Entity.Source", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Source");
});
modelBuilder.Entity("Entity.Users", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("IdImage")
.HasColumnType("int");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("IdImage");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "dev@gmail.com",
IdImage = 1,
Password = "1234",
UserName = "Dev"
},
new
{
Id = 2,
Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "admin@gmail.com",
IdImage = 1,
Password = "1234",
UserName = "Admin"
});
});
modelBuilder.Entity("Entity.Users", b =>
{
b.HasOne("Entity.Images", "Images")
.WithMany("Users")
.HasForeignKey("IdImage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Images");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Navigation("Users");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,89 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class migr2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "IdImage",
table: "Users",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.InsertData(
table: "Images",
columns: new[] { "Id", "ImgPath" },
values: new object[,]
{
{ 1, "coucou" },
{ 2, "bonjour" }
});
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "Id",
keyValue: 1,
column: "IdImage",
value: 1);
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" },
values: new object[] { 2, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "admin@gmail.com", 1, "1234", "Admin" });
migrationBuilder.CreateIndex(
name: "IX_Users_IdImage",
table: "Users",
column: "IdImage");
migrationBuilder.AddForeignKey(
name: "FK_Users_Images_IdImage",
table: "Users",
column: "IdImage",
principalTable: "Images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Users_Images_IdImage",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Users_IdImage",
table: "Users");
migrationBuilder.DeleteData(
table: "Images",
keyColumn: "Id",
keyValue: 2);
migrationBuilder.DeleteData(
table: "Users",
keyColumn: "Id",
keyValue: 2);
migrationBuilder.DeleteData(
table: "Images",
keyColumn: "Id",
keyValue: 1);
migrationBuilder.DropColumn(
name: "IdImage",
table: "Users");
}
}
}

@ -0,0 +1,245 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(StubWTFContext))]
partial class StubWTFContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Entity.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Character");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImgPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Images");
b.HasData(
new
{
Id = 1,
ImgPath = "coucou"
},
new
{
Id = 2,
ImgPath = "bonjour"
});
});
modelBuilder.Entity("Entity.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerB")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerD")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrectAnswer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("Entity.Quiz", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("NbQuestion")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Quiz");
});
modelBuilder.Entity("Entity.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<int>("Langage")
.HasColumnType("int");
b.Property<int>("Likes")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Quote");
});
modelBuilder.Entity("Entity.Source", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Source");
});
modelBuilder.Entity("Entity.Users", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("IdImage")
.HasColumnType("int");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("IdImage");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "dev@gmail.com",
IdImage = 1,
Password = "1234",
UserName = "Dev"
},
new
{
Id = 2,
Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "admin@gmail.com",
IdImage = 1,
Password = "1234",
UserName = "Admin"
});
});
modelBuilder.Entity("Entity.Users", b =>
{
b.HasOne("Entity.Images", "Images")
.WithMany("Users")
.HasForeignKey("IdImage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Images");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Navigation("Users");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Contextlib;
using Entity;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib
{
public class StubWTFContext : WTFContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Images>()
.HasMany(i => i.Users)
.WithOne(u => u.Images)
.HasForeignKey(u => u.IdImage)
.IsRequired();
modelBuilder.Entity<Images>().HasData(
new Images { Id = 1, ImgPath = "coucou" },
new Images { Id = 2, ImgPath = "bonjour" }
);
modelBuilder.Entity<Users>().HasData(
new Users { Id = 1, UserName = "Dev", Created = new DateTime(2000, 01, 01), Email = "dev@gmail.com", Password = "1234", IdImage = 1 },
new Users { Id = 2, UserName = "Admin", Created = new DateTime(2000, 01, 01), Email = "admin@gmail.com", Password = "1234", IdImage = 1 }
);
}
}
}

@ -6,4 +6,16 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contextlib\Contextlib.csproj" />
<ProjectReference Include="..\Entity\Entity.csproj" />
</ItemGroup>
</Project>

@ -3,25 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{792EF125-E2D4-457C-B536-BDAEFB49D14E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{792EF125-E2D4-457C-B536-BDAEFB49D14E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entity", "Entity\Entity.csproj", "{69A4450C-AA43-4622-A866-9A5F7C8A2C14}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entity", "Entity\Entity.csproj", "{69A4450C-AA43-4622-A866-9A5F7C8A2C14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contextlib", "Contextlib\Contextlib.csproj", "{32977454-CE94-4532-AE26-29F6951B78CF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contextlib", "Contextlib\Contextlib.csproj", "{32977454-CE94-4532-AE26-29F6951B78CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{5CD69B14-C6AE-4628-A374-996C486E25F2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{5CD69B14-C6AE-4628-A374-996C486E25F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestModel2Entities", "TestModel2Entities\TestModel2Entities.csproj", "{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestModel2Entities", "TestModel2Entities\TestModel2Entities.csproj", "{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Model\Entities.csproj", "{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model2Entities", "Model2entities\Model2Entities.csproj", "{4A1CBA3D-C798-4E19-865F-39F919F1205A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model2Entities", "Model2entities\Model2Entities.csproj", "{4A1CBA3D-C798-4E19-865F-39F919F1205A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTest", "XUnitTest\XUnitTest.csproj", "{48002CA2-7CFF-4077-90CF-392476320CE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTest", "XUnitTest\XUnitTest.csproj", "{48002CA2-7CFF-4077-90CF-392476320CE3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WfApi", "WfApi\WfApi.csproj", "{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WfApi", "WfApi\WfApi.csproj", "{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{708875DC-7ED1-4FD1-9321-3E00B2E7709B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -53,10 +53,6 @@ Global
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.Build.0 = Release|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C51815EE-ED06-4F38-955E-7EBB72C0A7EF}.Release|Any CPU.Build.0 = Release|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -69,6 +65,10 @@ Global
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.Build.0 = Release|Any CPU
{708875DC-7ED1-4FD1-9321-3E00B2E7709B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{708875DC-7ED1-4FD1-9321-3E00B2E7709B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{708875DC-7ED1-4FD1-9321-3E00B2E7709B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{708875DC-7ED1-4FD1-9321-3E00B2E7709B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save