Exemplo n.º 1
0
        public EfUnitOfWork(ConfigDbContext dbContext)
        {
            //Database.SetInitializer<ConfigDbContext>(null);

            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext can not be null.");
            }

            _dbContext = dbContext;
        }
Exemplo n.º 2
0
        public static void Initialize(ConfigDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.Configurations.Any())
            {
                return;   // DB has been seeded
            }

            var configs = new Config[]
            {
                new Config {
                    ApplicationName = "ServiceTraining", Id = Guid.NewGuid(), IsActive = true, Name = "Deneme", Type = "String", Value = "Deneme"
                }
            };

            foreach (var item in configs)
            {
                context.Configurations.Add(item);
            }
            context.SaveChanges();
        }