예제 #1
0
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            MapContext context = app.ApplicationServices.GetRequiredService <MapContext>();

            context.Database.Migrate();
            if (!context.Places.Any())
            {
                context.Places.AddRange(
                    new Place {
                    Name = "Place1"
                },
                    new Place {
                    Name = "Place2"
                },
                    new Place {
                    Name = "Place3"
                }
                    );
                context.SaveChanges();
            }
            if (!context.Users.Any())
            {
                context.Users.AddRange(
                    new User {
                    Name = "User1"
                },
                    new User {
                    Name = "User2"
                },
                    new User {
                    Name = "User2"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #2
0
 public MapRepository(MapContext context)
 {
     this.context = context;
 }