Added database models
This commit is contained in:
25
src/Portfolio.Api/DatabaseContext.cs
Normal file
25
src/Portfolio.Api/DatabaseContext.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Portfolio.Shared.Models;
|
||||
|
||||
namespace Portfolio.Api;
|
||||
|
||||
public class DatabaseContext(DbContextOptions<DatabaseContext> options) : DbContext(options) {
|
||||
|
||||
public DbSet<Project> Projects { get; set; }
|
||||
|
||||
public DbSet<Language> Languages { get; set; }
|
||||
|
||||
public DbSet<Technology> Technologies { get; set; }
|
||||
|
||||
public DbSet<TimelineEntry> Timeline { get; set; }
|
||||
|
||||
public DbSet<About> About { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) {
|
||||
modelBuilder.Entity<Project>()
|
||||
.HasMany(p => p.Languages)
|
||||
.WithMany()
|
||||
.UsingEntity("ProjectLanguage");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user