Following the instructions available at https://polecat.jasperfx.net/documents/initial-data.html, I have defined the following configuration:
builder.Services.AddPolecat(options =>
{
options.ConnectionString = "...";
options.InitialData.Add(new SeedUsers());
});
public class SeedUsers : IInitialData
{
public async Task Populate(IDocumentStore store, CancellationToken cancellationToken)
{
await using var session = store.LightweightSession();
if (await session.Query<User>().AnyAsync(cancellationToken))
{
return;
}
var roles = new[] { "Administrator", "User", "Manager", "Reviewer", "Contributor" };
var faker = new Faker<User>("en")
.RuleFor(u => u.Id, _ => Guid.NewGuid())
.RuleFor(u => u.FirstName, f => f.Name.FirstName())
.RuleFor(u => u.LastName, f => f.Name.LastName());
session.Store(faker.Generate(50).ToArray());
await session.SaveChangesAsync(cancellationToken);
}
}
However, I have verified that the seeding is not executed unless I call the ApplyAllDatabaseChangesOnStartup method after AddPolecat. When I do so, I notice that additional tables are created in the database besides pc_doc_user:
On the other hand, if I do not call the ApplyAllDatabaseChangesOnStartup method, even if the seeding does not run, when I try to work with the User documents, only the pc_doc_user table is created.
Following the instructions available at https://polecat.jasperfx.net/documents/initial-data.html, I have defined the following configuration:
However, I have verified that the seeding is not executed unless I call the
ApplyAllDatabaseChangesOnStartupmethod afterAddPolecat. When I do so, I notice that additional tables are created in the database besides pc_doc_user:On the other hand, if I do not call the
ApplyAllDatabaseChangesOnStartupmethod, even if the seeding does not run, when I try to work with the User documents, only the pc_doc_user table is created.