Ejemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcFriendsSiteContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcFriendsSiteContext> >()))
            {
                // Look for any movies.
                if (context.UserModel.Any())
                {
                    return;   // DB has been seeded
                }

                context.UserModel.AddRange(
                    new UserModel
                {
                    userName      = "******",
                    gender        = "Male",
                    alias         = "david",
                    website       = "david.com",
                    socialWebsite = "social.com/david",
                    email         = "*****@*****.**",
                    dob           = DateTime.Parse("1992-12-2"),
                },
                    new UserModel
                {
                    userName      = "******",
                    gender        = "Male",
                    alias         = "Andrew",
                    website       = "Andrew.com",
                    socialWebsite = "social.com/Andrew",
                    email         = "*****@*****.**",
                    dob           = DateTime.Parse("1994-12-6"),
                }


                    );
                context.SaveChanges();
            }
        }
 public UserModelsController(MvcFriendsSiteContext context)
 {
     _context = context;
 }
 public SocialModelsController(MvcFriendsSiteContext context)
 {
     _context = context;
 }
 public BlogPostsController(MvcFriendsSiteContext context)
 {
     _context = context;
 }