API updates for functional code

This commit is contained in:
programmingPug
2025-01-04 12:28:05 -05:00
parent a426dce05e
commit dd1196af84
44 changed files with 12280 additions and 5161 deletions

View File

@@ -0,0 +1,31 @@
namespace house_plant_api.Context
{
using house_plant_api.Models;
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
{
public DbSet<Device> Devices { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Device>()
.HasKey(d => d.Id);
modelBuilder.Entity<Device>()
.Property(d => d.Name)
.IsRequired();
modelBuilder.Entity<Device>()
.Property(d => d.Nickname);
modelBuilder.Entity<Device>()
.Property(d => d.Uuid)
.IsRequired();
}
}
}