Example #1
0
        public static void Seed(DbContext context)
        {
            // context.Database.Migrate();// Bekleyen migrationları veritabanına ekler

            if (context.Database.GetPendingMigrations().Count() == 0)
            {
                if (context is CourseAppContext)
                {
                    //CourseAppContext
                    CourseAppContext _context = context as CourseAppContext;
                    if (_context.Instructors.Count() == 0)
                    {
                        _context.Instructors.AddRange(Instructors);
                    }

                    if (_context.Courses.Count() == 0)
                    {
                        _context.Courses.AddRange(Courses);
                    }
                }

                if (context is UserContext)
                {
                    UserContext _context = context as UserContext;
                    if (_context.Users.Count() == 0)
                    {
                        _context.Users.AddRange(Users);
                    }
                }
                context.SaveChanges();
            }
        }
 public EfCourseRepository(CourseAppContext context)
 {
     _context = context;
 }
 public EfInstructorRepository(CourseAppContext context) : base(context)
 {
     _context = context;
 }