Problem
I am coding a proof of concept ASP.NET 5 MVC6 that will mimic a library. I use CTP6 and beta3.
How to determine their relationship in Entity Framework 7 using the first code approach?
Shelf and books need a join table. As I see it, this application will consider one shelf at a time and books on this "I". In other words, one shelf is related to each other with books.
Models
Shelf Model:
public class Shelf
{
public int ShelfId { get; set; }
public string ShelfName { get; set; }
public ShelfType MyProperty { get; set; }
public virtual List<Book> Books { get; set; }
public DateTime Created { get; set; }
public string CreatedBy { get; set; }
public DateTime Updated { get; set; }
public string UpdatedBy { get; set; }
}
Book Model:
public class Book
{
public int BookId { get; set; }
public string BookName { get; set; }
public string BookAuthor { get; set; }
public string BookGenre { get; set; }
public DateTime BookPublishedDate { get; set; }
public string Description { get; set; }
public DateTime Created { get; set; }
public string CreatedBy { get; set; }
public DateTime Updated { get; set; }
public string UpdatedBy { get; set; }
}
purpose
I would like to implement something like this in ASP.NET 5. Since TPH and other functions are not yet implemented in EF7, am I on the right track?
In other words, I think the following:
- ShelfBookViewModel ( , , , ). , , ShelfBook. , -, .
- , EF7 , viewmodels . SOLID . - ( ).
- EF7, ?
, :
modelBuilder.Entity<Shelf>()
.HasMany(p => p.Shelfs)
.WithMany(t => t.Books)
.Map(mc =>
{
mc.ToTable("ShelfJoinBook");
mc.MapLeftKey("ShelfId");
mc.MapRightKey("BookId");
});
, . , .