I have built my project using DbContext. I have created and populated database tables using code-first migration. Lately I have realized that I will need to implement Identity framework into my project. DbContext of course didn't create identity tables in DB so I was wondering what would be a best way to "replace" DbContext by IdentityDbContext so I can run 'add-migration' and update DB. This is my DbContext class which I'm using all along my project:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using Milos_MovieStore.Models;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Milos_MovieStore.DAL
{
public class DBContext_MovieStore : DbContext
{
public DbSet<Customer> Customers { get; set; }
public DbSet<MembershipType> MembershipTypes { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<Genre> Genres { get; set; }
}
}
... when I changed base class to:
public class DBContext_MovieStore : IdentityDbContext<ApplicationUser>
{
public DbSet<Customer> Customers { get; set; }
public DbSet<MembershipType> MembershipTypes { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<Genre> Genres { get; set; }
}
... it simply didn't work (EF exceptions etc.) not to mention VS2017 crashed every time I tried to add new migration. The question is what would be proper way to implement Identity into project.