Upload
pallavi-patil
View
218
Download
0
Embed Size (px)
Citation preview
7/23/2019 EF DataKeyAnnotation Snippet
1/1
[Table("BlogPosts")]public class BlogPost{ [Key] public Guid Id { get; set; } public string Title { get; set; } public string Content { get; set; } public DateTime PublishDate { get; set; }
[ForeignKey("Category")] public Guid CategoryId { get; set; }
public virtual Category Category { get; set; }}[Table("Categories")]public class Category{ [Key] public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection BlogPosts { get; set; }}