2018-12-19 12:55:35 +01:00
|
|
|
|
using System.Data.Entity;
|
|
|
|
|
using Forum.DataAccessLayer.Models;
|
|
|
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
2018-12-01 22:12:59 +01:00
|
|
|
|
|
|
|
|
|
namespace Forum.DataAccessLayer
|
|
|
|
|
{
|
|
|
|
|
public class ApplicationDbContext : IdentityDbContext<ProfessionalUser>
|
|
|
|
|
{
|
|
|
|
|
public ApplicationDbContext()
|
|
|
|
|
: base("DefaultConnection", throwIfV1Schema: false)
|
2018-12-02 00:19:58 +01:00
|
|
|
|
{
|
2018-12-01 22:12:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ApplicationDbContext Create()
|
|
|
|
|
{
|
|
|
|
|
return new ApplicationDbContext();
|
|
|
|
|
}
|
2018-12-01 22:41:14 +01:00
|
|
|
|
|
|
|
|
|
public DbSet<Answer> Answers { get; set; }
|
|
|
|
|
|
|
|
|
|
public DbSet<Question> Questions { get; set; }
|
|
|
|
|
|
|
|
|
|
public DbSet<Category> Categories { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Question>().HasMany(a => a.Answers).WithOptional(q => q.Question);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Answer>().HasOptional(p => p.Professional);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Category>().HasMany(q => q.Questions).WithRequired(c => c.Category);
|
|
|
|
|
|
|
|
|
|
}
|
2018-12-01 22:12:59 +01:00
|
|
|
|
}
|
|
|
|
|
}
|