API updates for functional code

This commit is contained in:
programmingPug committed 2025-01-04 12:28:05 -05:00
1 parent a426dce05e
commit dd1196af84
44 files changed
+12280 -5161

No files matched your search

+31
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();
}
}
}