Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
Created June 14, 2018 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielplawgo/d0cc33f21e53033a649f586472a31ade to your computer and use it in GitHub Desktop.
Save danielplawgo/d0cc33f21e53033a649f586472a31ade to your computer and use it in GitHub Desktop.
Nbuilder oraz Faker.NET
protected override void Seed(NugetForAspMvc.Models.DataContext context)
{
if (context.Users.Any() == false)
{
var users = Builder<User>.CreateListOfSize(20)
.All()
.With(u => u.Email = Faker.Internet.Email())
.With(u => u.FirstName = Faker.Name.First())
.With(u => u.LastName = Faker.Name.Last())
.With(u => u.UserName = Faker.Internet.UserName())
.Build();
foreach (var user in users)
{
context.Users.AddOrUpdate(u => u.Email, user);
}
}
}
var users = Builder<User>.CreateListOfSize(10).Build();
var firstName = Faker.Name.First()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment