Tentei realizar o desafio do Entity framework parte 1, porém no meio do caminho me perdi completamente e não sei mais o que faço
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Alura.Filmes.App.Negocio;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Alura.Filmes.App.Dados
{
public class FilmeCategoriaConfiguration : IEntityTypeConfiguration<FilmeCategoria>
{
public void Configure(EntityTypeBuilder<FilmeCategoria> builder)
{
builder
.ToTable("film_category");
builder
.Property<int>("category_id")
.IsRequired();
builder
.Property<int>("film_id")
.IsRequired();
builder
.Property<DateTime>("last_update")
.HasDefaultValueSql("getdate()")
.HasColumnType("datetime")
.IsRequired();
builder
.HasKey("category_id", "film_id");
builder
.HasOne(fc => fc.Categoria)
.WithMany(f => f.Filmes);
builder
.HasOne(fc => fc.Filme)
.WithMany(f => f.Categoria);
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alura.Filmes.App.Dados
{
class FilmeConfiguration : IEntityTypeConfiguration<Filme>
{
public void Configure(EntityTypeBuilder<Filme> builder)
{
builder
.ToTable("film");
builder
.Property(f => f.Titulo)
.IsRequired()
.HasColumnType("varchar(255)")
.HasColumnName("title");
builder
.Property(f => f.Descricao)
.IsRequired()
.HasColumnName("description")
.HasColumnType("text");
builder
.Property(f => f.Id)
.HasColumnName("film_id");
builder
.Property(f => f.AnoLancamento)
.IsRequired()
.HasColumnName("release_year")
.HasColumnType("varchar(4)");
builder
.Property<DateTime>("last_update")
.IsRequired()
.HasColumnType("datetime");
builder
.Property(F => F.Duracao)
.HasColumnName("length");
builder
.Property<byte>("language_id")
.IsRequired();
builder
.Property<byte?>("original_language_id")
.IsRequired();
builder
.HasOne(f => f.IdiomaFalado)
.WithMany(i => i.FilmesFalados)
.HasForeignKey("language_id");
builder
.HasOne(f => f.IdiomaOriginal)
.WithMany(i => i.FilmesOriginais)
.HasForeignKey("original_language_id");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Alura.Filmes.App.Negocio;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Alura.Filmes.App.Dados
{
public class CategoriasConfiguration : IEntityTypeConfiguration<Categorias>
{
public void Configure(EntityTypeBuilder<Categorias> builder)
{
builder
.ToTable("category");
builder
.Property(c => c.Id)
.HasColumnName("category_id");
builder
.Property(c => c.Nome)
.HasColumnName("name")
.HasColumnType("varchar(25)")
.IsRequired();
builder
.Property<DateTime>("last_update")
.HasDefaultValueSql("getdate()")
.HasColumnType("datetime")
.IsRequired();
}
}
}