diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2be6f42 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "C#: Debug", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}/.csproj" + } + + ] +} \ No newline at end of file diff --git a/AdapterContext.cs b/AdapterContext.cs new file mode 100644 index 0000000..b9ad571 --- /dev/null +++ b/AdapterContext.cs @@ -0,0 +1,89 @@ +using Db.Models; +using Microsoft.EntityFrameworkCore; + +public class AdapterContext : DbContext +{ + public AdapterContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + // Configure your entity mappings here + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(e => + { + e.HasKey(vt => new { vt.VideoId, vt.TagId }); + e.HasOne(vt => vt.Video) + .WithMany(v => v.VideoTags) + .HasForeignKey(vt => vt.VideoId); + e.HasOne(vt => vt.Tag) + .WithMany(t => t.VideoTags) + .HasForeignKey(vt => vt.TagId); + }); + + modelBuilder.Entity