Last post Jan 08, 2015 03:08 AM by Zhi Lv - MSFT
Jan 07, 2015 02:46 AM|itman1981|LINK
I want to know how can i run seed method without using "update-database"
Jan 07, 2015 03:18 AM|Mikesdotnetting|LINK
Why don't you want to use the update-database command to run the Seed method?
Jan 07, 2015 03:32 AM|itman1981|LINK
Thanks for response. I would like to know is there any other alternative to update-database
Jan 07, 2015 04:10 AM|Mikesdotnetting|LINK
You can take the code that runs in the Seed method and put it into a different method in a public class. Then you can call that method using a Console app or from a web page. These similar threads on Stackoverflow should help:
Jan 07, 2015 05:02 AM|itman1981|LINK
Thank you for response. after doing research I found "Database.SetInitializer". Actually my target is to initialize DB with default data using "EF"
Jan 07, 2015 05:15 AM|Mikesdotnetting|LINK
So you aren't using migrations?
Jan 08, 2015 03:08 AM|Zhi Lv - MSFT|LINK
As you said, you could use Database.SetInitializer() method. Here are some articles about it, please refer to them.
Use of Database.SetInitializer() method in Code First
Database Initialization Strategies in Code-First: