Beispiel #1
0
        public static void Initialize(SocialMediaContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.Users.AddRange(new List <UserEntity>
            {
                new UserEntity
                {
                    Email    = "*****@*****.**",
                    Login    = "******",
                    Password = "******",
                    Status   = UserStatus.Unauthorized,
                    Image    = System.IO.File.ReadAllBytes("event.png")
                },
                new UserEntity
                {
                    Email    = "*****@*****.**",
                    Login    = "******",
                    Password = "******",
                    Status   = UserStatus.Unauthorized,
                    Image    = System.IO.File.ReadAllBytes("event.png")
                },
                new UserEntity
                {
                    Email    = "chel3232",
                    Login    = "******",
                    Password = "******",
                    Status   = UserStatus.Unauthorized,
                    Image    = System.IO.File.ReadAllBytes("event.png")
                }
            });
            context.SaveChanges();

            context.Followings.AddRange(new List <FollowEntity>
            {
                new FollowEntity
                {
                    FollowerId = 1,
                    FollowedId = 2
                },
                new FollowEntity
                {
                    FollowerId = 2,
                    FollowedId = 2
                }
            });
            context.SaveChanges();

            var u = context.Users.ToList();
            var q = context.Followings.ToList();
        }
 public void SaveChanges()
 {
     AppContext.SaveChanges();
 }