Seed method not called, Entity Framework 6

前端 未结 7 795
我在风中等你
我在风中等你 2020-12-28 18:29

I have a DatabaseInitializer class

public class DatabaseInitializer : CreateDatabaseIfNotExists
{
    protected override          


        
相关标签:
7条回答
  • 2020-12-28 19:09

    to get Seed method to be called when you are not using AutomaticMigration, you should use MigrateDatabaseToLatestVersion initializer for your code-first database.
    like this:

    Database.SetInitializer(new MigrateDatabaseToLatestVersion<YourContext,YourConfiguration>());  
    

    this way, Seed method will be called every time the migration is done successfully.

    0 讨论(0)
提交回复
热议问题