Exemple #1
0
        //------------------------------------------------
        //Amdin commands that are called from the top menu

        public IActionResult ResetDatabase()
        {
            Request.ThrowErrorIfNotLocal();

            _context.DevelopmentEnsureCreated();
            var numBooks = _context.SeedDatabase(_env.WebRootPath);

            SetupTraceInfo();
            return(View("BookUpdated", $"Successfully reset the database and added {numBooks} books."));
        }
Exemple #2
0
        //------------------------------------------------
        //Amdin commands that are called from the top menu

        public IActionResult ResetDatabase([FromServices] EfCoreContext context, [FromServices] IHostingEnvironment env)
        {
            Request.ThrowErrorIfNotLocal();

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            var numBooks = context.SeedDatabase(env.WebRootPath);

            SetupTraceInfo();
            return(View("BookUpdated", $"Successfully reset the database and added {numBooks} books."));
        }