0

I created an ASP.NET Core web application using the Visual Studio wizard, which generated all the DbContext stuff. I am currently trying to implement the Enum Lookup Table Generator package. The documentation says:

Run EnumToLookup.Apply() from your Seed method in either your database initializer or your EF Migrations.

My issue is that my DbContext does not currently use a database initializer.

Where should I run EnumToLookup.Apply()? Do I need to add a database initializer so that I can override the Seed() method where the documentation says to put EnumToLookup.Apply()?

My DbContext looks like this:

namespace WebApplication3.Data
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
        }

        public DbSet<WebApplication3.Models.Restaurant> Restaurant { get; set; }
        public DbSet<WebApplication3.Models.Customer> Customer { get; set; }
    }
}
Josh Withee
  • 9,922
  • 3
  • 44
  • 62

1 Answers1

1

I did some more research and it turns out that while EF6 had the ability to add seed data, EF7 / EF Core 2.0 does not include this ability.

This functionality may be added with the release of EF Core 2.1, but it might not make it in.

Josh Withee
  • 9,922
  • 3
  • 44
  • 62
  • 2
    [Data seeding](https://learn.microsoft.com/en-us/ef/core/modeling/data-seeding) will be added in EF Core 2.1. Migrations has supported Insert, Update, and Delete operations since verstion 2.0. – bricelam Mar 05 '18 at 18:10
  • @bricelam Thanks for the info! – Josh Withee Mar 06 '18 at 01:56