There is a certain model:
public class Post { public int Id { get; set; } [Column(TypeName = "date")] public DateTime? PostedDate { get; set; } [Column(TypeName = "text")] public string Body { get; set; } public int UserId { get; set; } public virtual User User { get; set; } public Post() { Comments = new HashSet<PostComment>(); } } public class ApplicationUser : IdentityUser { public int Id { get; set; } [Column(TypeName = "date")] public DateTime RegistrationDate { get; set; } [Column(TypeName = "date")] public DateTime LastVisit { get; set; } public virtual ICollection<Post> Posts { get; set; } public ApplicationUser() { Users = new HashSet<User>(); } }
and context
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false) { } public virtual DbSet<Post> Posts { get; set; } public static ApplicationDbContext Create() { return new ApplicationDbContext(); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { ... } }
Tell me: - How to wrap all this in the Repository pattern?
- How to spread everything across assemblies ( Entities (Same model), DataAccess (Context, DB settings), Repository (Pattern repository), Services (Services for working with ViewModel) and Web assembly itself (ASP.NET MVC 5))?
ApplicationDbContext
class. Its property -DbSet<Post> Posts
- this is the "interface in the form of a collection". it is therefore not entirely clear what and what you want to wrap. - PashaPash ♦ApplicationDbContext
in turn (I think) tightly binds us to a specific ORM, i.e. to EF. I also want to try to implement this pattern as a practice. project training. @PashaPash - Aleksandr