You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
markjerz edited this page Jan 8, 2016
·
2 revisions
It's a common requirement that databases have a set of pre-seeded data in them for general use e.g. a table of countries
or currency codes.
Regardless of what you're seeding you simply need to implement ISeeder in your configuration
public class DashingConfiguration : DefaultConfiguration, ISeeder {
public DashingConfiguration()
: base(ConfigurationManager.ConnectionStrings["DefaultDb"]) {
this.AddNamespaceOf<Blog>();
}
public void Seed(ISession session) {
// insert some data here
}
}
In general, you'll want to make sure that this method is idempotent i.e. if you create some data in here it's not created
every time Seed is called. This function is called by the dbm tool every time
the database is migrated.
You may want to make use of the InsertOrUpdate<T> method on the ISession