Ejemplo n.º 1
0
        /// <summary>
        /// <para>Seeds the database with data if the tables are empty.</para>
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static int EnsureSeedData(this DatabaseContext context)
        {
            int sum = 0;

            var dbSeeder = new DatabaseSeeder(context);

            if (!context.Users.Any())
            {
                sum += dbSeeder.SeedUserEntitiesFromJson().Result;
            }
            if (!context.Anchors.Any())
            {
                sum += dbSeeder.SeedAnchorEntitiesFromJson().Result;
            }

            return(sum);
        }