public class Blog { public string ID { get; set; } public string BlogName { get; set; } public string BlogAuthor { get; set; } public virtual List <Post> Posts { get; set ; } //导航属性 public virtual List <Article> Articles { get; set; } //导航属性 [ Timestamp] public byte [] version { get; set; } } public class Post { public string ID { get; set; } public string PostName { get; set; } public string Content { get; set; } public virtual Blog BelongBlog { get; set; } //导航属性 } public class Article { public string ID { get; set; } public string ArticleName { get; set; } public string Content { get; set; } }
public Person CreatedBy { get; set; } public Person UpdatedBy { get; set; }
public virtual List<Post> PostsWritten { get; set; } public virtual List <Post> PostsUpdated { get; set ; }
[InverseProperty( "CreatedBy")] public virtual List <Post> PostsWritten { get; set ; } [ InverseProperty("UpdatedBy" )] public virtual List <Post> PostsUpdated { get; set ; }
public class Student { public int StudentID { get; set; } public string Name { get; set; } public List <Course> Courses { get; set ; } } public class Course { public int CourseID { get; set; } public string CourseName { get; set; } public List <Student> Students { get; set ; } }
public class Book { public int BookID { get; set; } public string Name { get; set; } public BookCover Cover { get; set; } } public class BookCover { [ Key , ForeignKey ("Coverof" )] public int BookID { get; set; } public byte [] Photo { get; set; } public Book Coverof { get; set; } }
原文:http://www.cnblogs.com/JasonShenW/p/5097814.html