locked
What is the seeding concept in Entity Framework RRS feed

  • Question

  • User264732274 posted

    i just like to know what is the seeding concept in Entity Framework ?

    i hard people say seed the work when they work with EF code first approach. so please guide me what does it mean seed in EF and what seed does?

    thanks

    Wednesday, October 7, 2015 4:44 AM

Answers

All replies

  • User753101303 posted

    Hi,

    Try http://www.entityframeworktutorial.net/code-first/seed-database-in-code-first.aspx

    EF can create the database for you and "seeding" just means inserting some initial data when the db is created (for example if you have a country table you may want to pre-populate this table with default countries etc...)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 7, 2015 5:03 AM
  • User264732274 posted

    suppose by EF we create a country table with two fields named ID and Name and seed with some initial data but we add more country data there. after few days we decide to add one more column in that table called culture by code first then what will happen..........my all data will be lost?

    what option we need to turn on as a result data should not be lost. if possible please discuss.

    thanks

    Wednesday, October 7, 2015 5:08 AM
  • User753101303 posted

    No, the ALTER TABLE MyTable ADD <column definition> statement allows to add a new column to an existing table. You can drive this through EF using https://msdn.microsoft.com/en-s/data/jj591621.aspx

    Wednesday, October 7, 2015 6:59 AM