Advertisement
Cassimus

DbContext

Sep 23rd, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using Microsoft.EntityFrameworkCore;
  2.  
  3. namespace KatalogGier
  4. {
  5. public class GamesContext : DbContext
  6. {
  7. internal DbSet<Game> Games { get; set; }
  8. internal DbSet<Publisher> Publisher { get; set; }
  9.  
  10.  
  11. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  12. {
  13. optionsBuilder.UseSqlite($"Data Source={Directory.GetCurrentDirectory}\\game.db");
  14. }
  15.  
  16. protected override void OnModelCreating(ModelBuilder modelBuilder)
  17. {
  18. modelBuilder.Entity<Game>()
  19. .HasOne(p => p.Publisher)
  20. .WithMany(g => g.Games);
  21. }
  22.  
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement