Skip to content

Instantly share code, notes, and snippets.

@httpmurilo
Last active June 24, 2020 21:11
Show Gist options
  • Save httpmurilo/35dedda9078cd57183131a3ae4ab1de3 to your computer and use it in GitHub Desktop.
Save httpmurilo/35dedda9078cd57183131a3ae4ab1de3 to your computer and use it in GitHub Desktop.
using Faculdade.Api.Model;
using Microsoft.EntityFrameworkCore;
namespace Faculdade.Api.Data
{
public class DataContext: DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{}
public DbSet<Autor> Autores {get;set;}
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<Autor>().HasData(
new Autor()
{
Id = 1,
Nome = "Antony Lima",
Curso = "Direito Criminal"
},
new Autor()
{
Id = 2,
Nome = "Marcos Cesar",
Curso = "Ciências"
},
new Autor()
{
Id = 3,
Nome = "Renato Souza",
Curso = "Matemática"
}
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment