Build qui marche , verifier que la supretion / insertion / deplacement marche entre :

- User/Commentary/Quote
- User/Favorite/Quote
pull/5/head
kekentin 1 month ago
parent d8f941f8ec
commit 8ccde0b125

@ -63,7 +63,7 @@ namespace Contextlib
public async Task DeleteCommentForUser(int userId) public async Task DeleteCommentForUser(int userId)
{ {
// Retrieve comments for the specific userId // Retrieve comments for the specific userId
var comments = await _context.comments.Where(x => x.IdUsers == userId).ToListAsync(); var comments = await _context.comments.Where(x => x.IdUser == userId).ToListAsync();
if (!comments.Any()) // If no comments exist for this userId if (!comments.Any()) // If no comments exist for this userId
{ {
throw new KeyNotFoundException($"No comments found for the user ID: {userId}."); throw new KeyNotFoundException($"No comments found for the user ID: {userId}.");

@ -34,17 +34,38 @@ namespace Contextlib
.UsingEntity<Favorite>( .UsingEntity<Favorite>(
l => l.HasOne(f => f.Quote) l => l.HasOne(f => f.Quote)
.WithMany() .WithMany()
.OnDelete(DeleteBehavior.ClientCascade)
.HasForeignKey(f => f.IdQuote), .HasForeignKey(f => f.IdQuote),
r => r.HasOne(f => f.Users) r => r.HasOne(f => f.Users)
.WithMany() .WithMany()
.OnDelete(DeleteBehavior.ClientCascade)
.HasForeignKey(f => f.IdUsers) .HasForeignKey(f => f.IdUsers)
); );
modelBuilder.Entity<Users>() modelBuilder.Entity<Users>()
.HasMany(u => u.Quotes) .HasMany(u => u.Quotes)
.WithOne(q => q.User) .WithOne(q => q.User)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasForeignKey(q => q.IdUsersPropose); .HasForeignKey(q => q.IdUsersPropose);
modelBuilder.Entity<Users>()
.HasMany<Quote>()
.WithMany()
.UsingEntity<Commentary>(
i => i.HasKey(e => new { e.IdUser, e.IdQuote })
);
modelBuilder.Entity<Commentary>()
.HasOne(c => c.User)
.WithMany()
.HasForeignKey(c => c.IdUser);
modelBuilder.Entity<Quote>()
.HasMany(q => q.Commentarys)
.WithOne(c => c.Quote)
.OnDelete(DeleteBehavior.ClientCascade)
.HasForeignKey(c => c.IdQuote);
modelBuilder.Entity<Quiz>() modelBuilder.Entity<Quiz>()
.HasMany(q => q.Questions) .HasMany(q => q.Questions)
.WithMany(u => u.Quizs) .WithMany(u => u.Quizs)

@ -16,7 +16,7 @@ namespace Entity
[Required] [Required]
[ForeignKey(nameof(Users))] [ForeignKey(nameof(Users))]
public int IdUsers { get; set; } public int IdUser { get; set; }
[Required] [Required]
[ForeignKey(nameof(Quote))] [ForeignKey(nameof(Quote))]
@ -32,6 +32,6 @@ namespace Entity
public Quote Quote { get; set; } = null!; public Quote Quote { get; set; } = null!;
public Users Users { get; set; } = null!; public Users User { get; set; } = null!;
} }
} }

@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[StringLength(50)] [StringLength(100)]
public string Content { get; set; } public string Content { get; set; }
[Required] [Required]
@ -35,11 +35,12 @@ namespace Entity
[ForeignKey(nameof(Source))] [ForeignKey(nameof(Source))]
public int IdSource { get; set; } public int IdSource { get; set; }
[Required]
[ForeignKey(nameof(Users))] [ForeignKey(nameof(Users))]
public int IdUsersPropose { get; set; } public int? IdUsersPropose { get; set; }
//Réson de pour quoi j'ai mis le user en nullable et mis .OnDelete(DeleteBehavior.ClientSetNull) dans WTFContext
public Users User { get; set; } = null!; //https://learn.microsoft.com/fr-fr/ef/core/saving/cascade-delete
//Les suppressions en cascade sont nécessaires quand une entité dépendante/enfant ne peut plus être associée à son entité principale/parente actuelle. Cela peut se produire à la suite de la suppression de lentité principale/parente, ou quand lentité principale/parente existe toujours mais que lentité dépendante/enfant ne lui est plus associée.
public Users? User { get; set; } = null!;
public Source Source { get; set; } = null!; public Source Source { get; set; } = null!;
@ -47,7 +48,7 @@ namespace Entity
public ICollection<DailyQuote> DailyQuotes { get; set; } = new List<DailyQuote>(); public ICollection<DailyQuote> DailyQuotes { get; set; } = new List<DailyQuote>();
public ICollection<Commentary> commentaries { get; set; } = new List<Commentary>(); public ICollection<Commentary> Commentarys { get; set; } = new List<Commentary>();
public ICollection<Users> Favorite { get; } = new List<Users>(); public ICollection<Users> Favorite { get; } = new List<Users>();
} }

@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[StringLength(50)] [StringLength(100)]
public string Title { get; set; } public string Title { get; set; }
[Required] [Required]

@ -37,8 +37,6 @@ namespace Entity
public ICollection<Quote> Quotes { get; set; } = new List<Quote>(); public ICollection<Quote> Quotes { get; set; } = new List<Quote>();
public ICollection<Commentary> Commentary { get; set; } = new List<Commentary>();
public ICollection<Quote> Favorite { get; set; } = new List<Quote>(); public ICollection<Quote> Favorite { get; set; } = new List<Quote>();
} }
} }

@ -12,7 +12,7 @@ using StubbedContextLib;
namespace StubbedContextLib.Migrations namespace StubbedContextLib.Migrations
{ {
[DbContext(typeof(StubWTFContext))] [DbContext(typeof(StubWTFContext))]
[Migration("20250314112216_migrationTest1")] [Migration("20250317163102_migrationTest1")]
partial class migrationTest1 partial class migrationTest1
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -112,11 +112,11 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Commentary", b => modelBuilder.Entity("Entity.Commentary", b =>
{ {
b.Property<int>("Id") b.Property<int>("IdUser")
.ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); b.Property<int>("IdQuote")
.HasColumnType("int");
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired() .IsRequired()
@ -127,36 +127,34 @@ namespace StubbedContextLib.Migrations
.HasColumnType("date") .HasColumnType("date")
.HasColumnName("DateCommentary"); .HasColumnName("DateCommentary");
b.Property<int>("IdQuote") b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdUsers") SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
.HasColumnType("int");
b.HasKey("Id"); b.HasKey("IdUser", "IdQuote");
b.HasIndex("IdQuote"); b.HasIndex("IdQuote");
b.HasIndex("IdUsers");
b.ToTable("comments"); b.ToTable("comments");
b.HasData( b.HasData(
new new
{ {
Id = 1, IdUser = 2,
IdQuote = 1,
Comment = "Ce film est le meilleur", Comment = "Ce film est le meilleur",
DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified),
IdQuote = 1, Id = 1
IdUsers = 2
}, },
new new
{ {
Id = 2, IdUser = 3,
IdQuote = 1,
Comment = "Very good", Comment = "Very good",
DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified),
IdQuote = 1, Id = 2
IdUsers = 3
}); });
}); });
@ -575,8 +573,8 @@ namespace StubbedContextLib.Migrations
b.Property<string>("Content") b.Property<string>("Content")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(100)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(100)");
b.Property<int>("IdCharacter") b.Property<int>("IdCharacter")
.HasColumnType("int"); .HasColumnType("int");
@ -584,7 +582,7 @@ namespace StubbedContextLib.Migrations
b.Property<int>("IdSource") b.Property<int>("IdSource")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdUsersPropose") b.Property<int?>("IdUsersPropose")
.HasColumnType("int"); .HasColumnType("int");
b.Property<bool>("IsValid") b.Property<bool>("IsValid")
@ -729,8 +727,8 @@ namespace StubbedContextLib.Migrations
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(100)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(100)");
b.Property<int>("TypeSrc") b.Property<int>("TypeSrc")
.HasColumnType("int"); .HasColumnType("int");
@ -923,20 +921,20 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Commentary", b => modelBuilder.Entity("Entity.Commentary", b =>
{ {
b.HasOne("Entity.Quote", "Quote") b.HasOne("Entity.Quote", "Quote")
.WithMany("commentaries") .WithMany("Commentarys")
.HasForeignKey("IdQuote") .HasForeignKey("IdQuote")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.HasOne("Entity.Users", "Users") b.HasOne("Entity.Users", "User")
.WithMany("Commentary") .WithMany()
.HasForeignKey("IdUsers") .HasForeignKey("IdUser")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Quote"); b.Navigation("Quote");
b.Navigation("Users"); b.Navigation("User");
}); });
modelBuilder.Entity("Entity.DailyQuote", b => modelBuilder.Entity("Entity.DailyQuote", b =>
@ -955,13 +953,13 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entity.Quote", "Quote") b.HasOne("Entity.Quote", "Quote")
.WithMany() .WithMany()
.HasForeignKey("IdQuote") .HasForeignKey("IdQuote")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.HasOne("Entity.Users", "Users") b.HasOne("Entity.Users", "Users")
.WithMany() .WithMany()
.HasForeignKey("IdUsers") .HasForeignKey("IdUsers")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.Navigation("Quote"); b.Navigation("Quote");
@ -1011,9 +1009,7 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entity.Users", "User") b.HasOne("Entity.Users", "User")
.WithMany("Quotes") .WithMany("Quotes")
.HasForeignKey("IdUsersPropose") .HasForeignKey("IdUsersPropose");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character"); b.Navigation("Character");
@ -1049,9 +1045,9 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Quote", b => modelBuilder.Entity("Entity.Quote", b =>
{ {
b.Navigation("DailyQuotes"); b.Navigation("Commentarys");
b.Navigation("commentaries"); b.Navigation("DailyQuotes");
}); });
modelBuilder.Entity("Entity.Source", b => modelBuilder.Entity("Entity.Source", b =>
@ -1061,8 +1057,6 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Users", b => modelBuilder.Entity("Entity.Users", b =>
{ {
b.Navigation("Commentary");
b.Navigation("Quotes"); b.Navigation("Quotes");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618

@ -50,7 +50,7 @@ namespace StubbedContextLib.Migrations
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Year = table.Column<int>(type: "int", nullable: false), Year = table.Column<int>(type: "int", nullable: false),
TypeSrc = table.Column<int>(type: "int", nullable: false) TypeSrc = table.Column<int>(type: "int", nullable: false)
}, },
@ -153,13 +153,13 @@ namespace StubbedContextLib.Migrations
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
Content = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Content = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Likes = table.Column<int>(type: "int", nullable: false), Likes = table.Column<int>(type: "int", nullable: false),
Langage = table.Column<int>(type: "int", nullable: false), Langage = table.Column<int>(type: "int", nullable: false),
IsValid = table.Column<bool>(type: "bit", nullable: false), IsValid = table.Column<bool>(type: "bit", nullable: false),
IdCharacter = table.Column<int>(type: "int", nullable: false), IdCharacter = table.Column<int>(type: "int", nullable: false),
IdSource = table.Column<int>(type: "int", nullable: false), IdSource = table.Column<int>(type: "int", nullable: false),
IdUsersPropose = table.Column<int>(type: "int", nullable: false) IdUsersPropose = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -180,33 +180,31 @@ namespace StubbedContextLib.Migrations
name: "FK_quotes_users_IdUsersPropose", name: "FK_quotes_users_IdUsersPropose",
column: x => x.IdUsersPropose, column: x => x.IdUsersPropose,
principalTable: "users", principalTable: "users",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "comments", name: "comments",
columns: table => new columns: table => new
{ {
IdUser = table.Column<int>(type: "int", nullable: false),
IdQuote = table.Column<int>(type: "int", nullable: false),
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
IdUsers = table.Column<int>(type: "int", nullable: false),
IdQuote = table.Column<int>(type: "int", nullable: false),
DateCommentary = table.Column<DateTime>(type: "date", nullable: false), DateCommentary = table.Column<DateTime>(type: "date", nullable: false),
Comment = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false) Comment = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_comments", x => x.Id); table.PrimaryKey("PK_comments", x => new { x.IdUser, x.IdQuote });
table.ForeignKey( table.ForeignKey(
name: "FK_comments_quotes_IdQuote", name: "FK_comments_quotes_IdQuote",
column: x => x.IdQuote, column: x => x.IdQuote,
principalTable: "quotes", principalTable: "quotes",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_comments_users_IdUsers", name: "FK_comments_users_IdUser",
column: x => x.IdUsers, column: x => x.IdUser,
principalTable: "users", principalTable: "users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
@ -243,14 +241,12 @@ namespace StubbedContextLib.Migrations
name: "FK_favorites_quotes_IdQuote", name: "FK_favorites_quotes_IdQuote",
column: x => x.IdQuote, column: x => x.IdQuote,
principalTable: "quotes", principalTable: "quotes",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_favorites_users_IdUsers", name: "FK_favorites_users_IdUsers",
column: x => x.IdUsers, column: x => x.IdUsers,
principalTable: "users", principalTable: "users",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.InsertData( migrationBuilder.InsertData(
@ -378,11 +374,11 @@ namespace StubbedContextLib.Migrations
migrationBuilder.InsertData( migrationBuilder.InsertData(
table: "comments", table: "comments",
columns: new[] { "Id", "Comment", "DateCommentary", "IdQuote", "IdUsers" }, columns: new[] { "IdQuote", "IdUser", "Comment", "DateCommentary", "Id" },
values: new object[,] values: new object[,]
{ {
{ 1, "Ce film est le meilleur", new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 2 }, { 1, 2, "Ce film est le meilleur", new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), 1 },
{ 2, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 3 } { 1, 3, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 2 }
}); });
migrationBuilder.InsertData( migrationBuilder.InsertData(
@ -420,11 +416,6 @@ namespace StubbedContextLib.Migrations
table: "comments", table: "comments",
column: "IdQuote"); column: "IdQuote");
migrationBuilder.CreateIndex(
name: "IX_comments_IdUsers",
table: "comments",
column: "IdUsers");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_favorites_IdUsers", name: "IX_favorites_IdUsers",
table: "favorites", table: "favorites",

@ -109,11 +109,11 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Commentary", b => modelBuilder.Entity("Entity.Commentary", b =>
{ {
b.Property<int>("Id") b.Property<int>("IdUser")
.ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); b.Property<int>("IdQuote")
.HasColumnType("int");
b.Property<string>("Comment") b.Property<string>("Comment")
.IsRequired() .IsRequired()
@ -124,36 +124,34 @@ namespace StubbedContextLib.Migrations
.HasColumnType("date") .HasColumnType("date")
.HasColumnName("DateCommentary"); .HasColumnName("DateCommentary");
b.Property<int>("IdQuote") b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdUsers") SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
.HasColumnType("int");
b.HasKey("Id"); b.HasKey("IdUser", "IdQuote");
b.HasIndex("IdQuote"); b.HasIndex("IdQuote");
b.HasIndex("IdUsers");
b.ToTable("comments"); b.ToTable("comments");
b.HasData( b.HasData(
new new
{ {
Id = 1, IdUser = 2,
IdQuote = 1,
Comment = "Ce film est le meilleur", Comment = "Ce film est le meilleur",
DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified),
IdQuote = 1, Id = 1
IdUsers = 2
}, },
new new
{ {
Id = 2, IdUser = 3,
IdQuote = 1,
Comment = "Very good", Comment = "Very good",
DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified),
IdQuote = 1, Id = 2
IdUsers = 3
}); });
}); });
@ -572,8 +570,8 @@ namespace StubbedContextLib.Migrations
b.Property<string>("Content") b.Property<string>("Content")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(100)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(100)");
b.Property<int>("IdCharacter") b.Property<int>("IdCharacter")
.HasColumnType("int"); .HasColumnType("int");
@ -581,7 +579,7 @@ namespace StubbedContextLib.Migrations
b.Property<int>("IdSource") b.Property<int>("IdSource")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdUsersPropose") b.Property<int?>("IdUsersPropose")
.HasColumnType("int"); .HasColumnType("int");
b.Property<bool>("IsValid") b.Property<bool>("IsValid")
@ -726,8 +724,8 @@ namespace StubbedContextLib.Migrations
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(100)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(100)");
b.Property<int>("TypeSrc") b.Property<int>("TypeSrc")
.HasColumnType("int"); .HasColumnType("int");
@ -920,20 +918,20 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Commentary", b => modelBuilder.Entity("Entity.Commentary", b =>
{ {
b.HasOne("Entity.Quote", "Quote") b.HasOne("Entity.Quote", "Quote")
.WithMany("commentaries") .WithMany("Commentarys")
.HasForeignKey("IdQuote") .HasForeignKey("IdQuote")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.HasOne("Entity.Users", "Users") b.HasOne("Entity.Users", "User")
.WithMany("Commentary") .WithMany()
.HasForeignKey("IdUsers") .HasForeignKey("IdUser")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Quote"); b.Navigation("Quote");
b.Navigation("Users"); b.Navigation("User");
}); });
modelBuilder.Entity("Entity.DailyQuote", b => modelBuilder.Entity("Entity.DailyQuote", b =>
@ -952,13 +950,13 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entity.Quote", "Quote") b.HasOne("Entity.Quote", "Quote")
.WithMany() .WithMany()
.HasForeignKey("IdQuote") .HasForeignKey("IdQuote")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.HasOne("Entity.Users", "Users") b.HasOne("Entity.Users", "Users")
.WithMany() .WithMany()
.HasForeignKey("IdUsers") .HasForeignKey("IdUsers")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.ClientCascade)
.IsRequired(); .IsRequired();
b.Navigation("Quote"); b.Navigation("Quote");
@ -1008,9 +1006,7 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entity.Users", "User") b.HasOne("Entity.Users", "User")
.WithMany("Quotes") .WithMany("Quotes")
.HasForeignKey("IdUsersPropose") .HasForeignKey("IdUsersPropose");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character"); b.Navigation("Character");
@ -1046,9 +1042,9 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Quote", b => modelBuilder.Entity("Entity.Quote", b =>
{ {
b.Navigation("DailyQuotes"); b.Navigation("Commentarys");
b.Navigation("commentaries"); b.Navigation("DailyQuotes");
}); });
modelBuilder.Entity("Entity.Source", b => modelBuilder.Entity("Entity.Source", b =>
@ -1058,8 +1054,6 @@ namespace StubbedContextLib.Migrations
modelBuilder.Entity("Entity.Users", b => modelBuilder.Entity("Entity.Users", b =>
{ {
b.Navigation("Commentary");
b.Navigation("Quotes"); b.Navigation("Quotes");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618

@ -72,8 +72,8 @@ namespace StubbedContextLib
); );
modelBuilder.Entity<Commentary>().HasData( modelBuilder.Entity<Commentary>().HasData(
new Commentary() { Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025,2,3), IdQuote = 1, IdUsers = 2 }, new Commentary() { Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025,2,3), IdQuote = 1, IdUser = 2 },
new Commentary() { Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11), IdQuote = 1, IdUsers = 3 } new Commentary() { Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11), IdQuote = 1, IdUser = 3 }
); );
modelBuilder.Entity<DailyQuote>().HasData( modelBuilder.Entity<DailyQuote>().HasData(

@ -18,8 +18,4 @@
<ProjectReference Include="..\Entity\Entity.csproj" /> <ProjectReference Include="..\Entity\Entity.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

Loading…
Cancel
Save