Example #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new SlutUppgiftContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <SlutUppgiftContext> >()))
            {
                if (context.Track.Any())
                {
                    return;   // DB has been seeded
                }

                context.Track.AddRange(
                    new Track
                {
                    Price       = 5,
                    Age         = 25,
                    FirstName   = "Pontus",
                    LastName    = "Fröjd",
                    PhoneNumber = "0737058360"
                },

                    new Track
                {
                    Price       = 5,
                    Age         = 25,
                    FirstName   = "Pontus",
                    LastName    = "Fröjd",
                    PhoneNumber = "0737058360"
                },

                    new Track
                {
                    Price       = 5,
                    Age         = 25,
                    FirstName   = "Pontus",
                    LastName    = "Fröjd",
                    PhoneNumber = "0737058360"
                },

                    new Track
                {
                    Price       = 5,
                    Age         = 25,
                    FirstName   = "Pontus",
                    LastName    = "Fröjd",
                    PhoneNumber = "0737058360"
                }
                    );
                context.SaveChanges();
            }
        }
 public User2Controller(SlutUppgiftContext context)
 {
     _context = context;
 }
Example #3
0
 public TracksController(SlutUppgiftContext context)
 {
     _context = context;
 }