But what would this seeder or Seed?
It is nothing more than predetermined data that will be entered in the database at its initialization.
It is directly related to migrations (Migrations)?
Not with Migrations itself, but rather in the concept of "Code First", ie where you create your database according to the model you data 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 are "installing" 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 no?
Another example would be the data in tables that will fill combobox
, cities/states, among many other examples.
Sniffing a little focus...
You commented on larable, but I will 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 will be inserted into the database.
I don’t know if it has anything to do with it, but maybe How computer randomization is generated?.
– Guilherme Lautert
@Guilhermelautert I think the name makes sense, but the purpose of the question does not. Seed is related to "sow" and Seeder "sower". On Laravel I saw that the Seeder serves to insert data in the database, but could not do this in Migration? So the confusion!
– Wallace Maxters
Seeder is the guy who has the full file on the machine :P >> torrents
– rray