When I run the migration, the database is creating but none of the tables are. I have no clue what I'm doing wrong as I did the same thing the other day with no issue. The initial migration ran and created the database but, none of the tables. I've tried deleting the db and migrations and doing the whole process over again with no luck. Below is some code and a picture of my folder structure. Hopefully someone can point out what I'm doing wrong.
Here is one of my models:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Workout_Tracker.Models
{
public class Exercise
{
public int ID { get; set; }
public int Weight { get; set; }
public string Name { get; set; }
public int WorkoutID { get; set; }
public Workout Workout { get; set; }
public IList<ExerciseSet> Sets { get; set; }
}
}
Here is my dbcontext:
namespace Workout_Tracker.Data
{
public class ApplicationDbContext : DbContext
{
public DbSet<User> Users;
public DbSet<Workout> Workouts;
public DbSet<Exercise> Exercises;
public DbSet<ExerciseSet> Exercise_Sets;
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
}
Here is a migration:
namespace Workout_Tracker.Migrations
{
public partial class first : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
Here is startup.cs:
namespace Workout_Tracker
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
And here is my folder structure: