InventoryAgent/Inventory.Core/InventoryContext.cs

23 lines
522 B
C#

using Microsoft.EntityFrameworkCore;
namespace Inventory.Core
{
public class InventoryContext : DbContext
{
public DbSet<Device> Devices { get; set; }
public InventoryContext(DbContextOptions<InventoryContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Device>()
.HasIndex(d => d.HardwareIdentifier)
.IsUnique();
}
}
}