Ejemplo n.º 1
0
        public static void Initialize(AppDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Database.EnsureCreated();


            // Look for any data available.
            if (context.Employees.Any())
            {
                return; // DB has been seeded
            }

            for (int i = 0; i < 10; i++)
            {
                var emp = EntityDataFactory <Employee> .Factory_Entity_Instance(
                    x =>
                {
                    x.Id          = 0;
                    x.ReportsToId = null;
                });

                context.Employees.Add(emp);
            }


            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void Initialize(AppDbContext context)
        {
            try
            {
                context.Database.EnsureDeleted();

                context.Database.EnsureCreated();

                // Look for any data available.
                if (context.Places.Any())
                {
                    return; // DB has been seeded
                }

                for (int i = 0; i < 10; i++)
                {
                    context.Places.Add(
                        EntityDataFactory <Place> .Factory_Entity_Instance(
                            x =>
                    {
                        x.State = "SP";
                    }));
                }

                int save = context.SaveChanges();
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                //throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public EntityControl()
 {
     Factory = new EntityDataFactory <T>(HrManagerContext.GetDbSetInstance <T>());
 }
Ejemplo n.º 4
0
 protected TEntity Factory_Entity <TEntity>(Action <TEntity> action = null)
 {
     return(EntityDataFactory <TEntity> .Factory_Entity_Instance(action));
 }