-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
DataSeeder.cs
38 lines (35 loc) · 1.49 KB
/
DataSeeder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using DeviceManager.Api.Constants;
using DeviceManager.Api.Data.Model;
using Microsoft.EntityFrameworkCore;
namespace DeviceManager.Api.Data.DataSeed
{
/// <inheritdoc/>
public class DataSeeder : IDataSeeder
{
/// <inheritdoc/>
public void SeedData(ModelBuilder modelBuilder)
{
// Add a new device group and add devices to the same
modelBuilder.Entity<DeviceGroup>().HasData(new DeviceGroup
{
DeviceGroupId = DataSeedingDefaultConstants.SeedDeviceGroupId,
Company = DataSeedingDefaultConstants.SeedDeviceGroupCompany,
OperatingSystem = DataSeedingDefaultConstants.SeedDeviceGroupOs
});
// Devices can be added using Device group also
modelBuilder.Entity<Device>().HasData(new Device
{
DeviceId = DataSeedingDefaultConstants.SeedDevice2Id,
DeviceCode = DataSeedingDefaultConstants.SeedDevice2Code,
DeviceTitle = DataSeedingDefaultConstants.SeedDevice2Title,
DeviceGroupId = DataSeedingDefaultConstants.SeedDeviceGroupId
}, new Device
{
DeviceId = DataSeedingDefaultConstants.SeedDevice1Id,
DeviceCode = DataSeedingDefaultConstants.SeedDevice1Code,
DeviceTitle = DataSeedingDefaultConstants.SeedDevice1Title,
DeviceGroupId = DataSeedingDefaultConstants.SeedDeviceGroupId
});
}
}
}