But what would this seeder or seed be?
This is nothing more than pre-determined data that will be inserted into the database at startup.
Is it directly related to migrations?
Not with migrations per se, but rather with the concept of "Code First", that is, where you create your database according to the data model that your application has.
And when should I use?
This concept is widely used in testing, but is not limited to testing. A good example is when you need to create a user whenever you "install" your system in a new environment. Instead of creating a user at hand, you can set up a seed user and password that will be automatically entered into the system, simple?
Another example would be data in tables that will populate combobox
, cities / states, among many other examples.
A little bit of focus ...
You've commented on larável, but I'll put an example with the Entity Framework here.
public class SchoolDBInitializer : DropCreateDatabaseAlways<SchoolDBContext>
{
protected override void Seed(SchoolDBContext context)
{
var user = new User{Name = "Admin", Password = "Admin"};
context.Users.Add(user );
base.Seed(context);
}
}
In this example, every time the database is initialized by the code, the Admin user is inserted into the database.