private void AddMapType(DemoContext _ctx) { var mapTypeMange = new mapTypes(); var mapTypes = mapTypeMange.GetMapTypes(); foreach (var type in mapTypes) { var mapType = _ctx.MapTypes.SingleOrDefault(x => x.Id == type.Id); if (mapType == null) { var newType = new MapType { Id = type.Id, Name = type.Name, Value = type.Value }; _ctx.MapTypes.Add(newType); _ctx.SaveChanges(); } } }
public DemoContextSeed(ILogger <DemoContextSeed> logger, DemoContext context) { _logger = logger; _ctx = context; }