Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Livro
- {
- public int Id { get; set; }
- public string Titulo { get; set; }
- public int AutorId { get; set; }
- [ForeignKey("AutorId")]
- public virtual Autor { get; set; }
- }
- public class Autor
- {
- public int Id { get; set; }
- public string Nome { get; set; }
- public virtual ICollection<Livro> Livros { get; set; }
- }
- public class Livro
- {
- public int Id { get; set; }
- public string Titulo { get; set; }
- public virtual Autor { get; set; }
- }
- public class Autor
- {
- public int Id { get; set; }
- public string Nome { get; set; }
- public virtual ICollection<Livro> Livros { get; set; }
- }
- CREATE TABLE Livro(
- Id INT NOT NULL,
- Nome NVARCHAR,
- PRIMARY KEY(Id)
- );
- CREATE TABLE Autor(
- Id INT NOT NULL,
- Titulo NVARCHAR,
- AutorId INT NOT NULL,
- FOREIGN KEY (AutorId) REFERENCES Livro (Id)
- PRIMARY KEY(Id)
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement