Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public class Livro
  2. {
  3. public int Id { get; set; }
  4. public string Titulo { get; set; }
  5. public int AutorId { get; set; }
  6.  
  7. [ForeignKey("AutorId")]
  8. public virtual Autor { get; set; }
  9. }
  10.  
  11. public class Autor
  12. {
  13. public int Id { get; set; }
  14. public string Nome { get; set; }
  15. public virtual ICollection<Livro> Livros { get; set; }
  16. }
  17.  
  18. public class Livro
  19. {
  20. public int Id { get; set; }
  21. public string Titulo { get; set; }
  22. public virtual Autor { get; set; }
  23. }
  24.  
  25. public class Autor
  26. {
  27. public int Id { get; set; }
  28. public string Nome { get; set; }
  29. public virtual ICollection<Livro> Livros { get; set; }
  30. }
  31.  
  32. CREATE TABLE Livro(
  33. Id INT NOT NULL,
  34. Nome NVARCHAR,
  35. PRIMARY KEY(Id)
  36. );
  37.  
  38. CREATE TABLE Autor(
  39. Id INT NOT NULL,
  40. Titulo NVARCHAR,
  41. AutorId INT NOT NULL,
  42. FOREIGN KEY (AutorId) REFERENCES Livro (Id)
  43. PRIMARY KEY(Id)
  44. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement