Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created August 28, 2018 12:51
Embed
What would you like to do?
Updated Formula 1 context with Points added to the racers
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Racer>().Property(r => r.Name)
.IsRequired()
.HasMaxLength(100);
modelBuilder.Entity<Racer>().Property(r => r.Team)
.IsRequired(false)
.HasMaxLength(60);
modelBuilder.Entity<Racer>().HasData(
new Racer { Id = 1, Name = "Lewis Hamilton", Team = "Mercedes", Points = 231 },
new Racer { Id = 2, Name = "Sebastian Vettel", Team = "Ferrari", Points = 214 },
new Racer { Id = 3, Name = "Kimi Räikkönen", Team = "Ferrari", Points = 146 },
new Racer { Id = 4, Name = "Valtteri Bottas", Team = "Mercedes", Points = 144 },
new Racer { Id = 5, Name = "Max Verstappen", Team = "Red Bull Racing", Points = 120 },
new Racer { Id = 6, Name = "Daniel Ricciardo", Team = "Red Bull Racing", Points = 118 }
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment