using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;

namespace Rkis29.Model
{
    public partial class Model1 : DbContext
    {
        public Model1()
            : base("name=Model11")
        {
        }

        public virtual DbSet<Person> Person { get; set; }
        public virtual DbSet<StatusTask> StatusTask { get; set; }
        //public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
        public virtual DbSet<Task> Task { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Person>()
                .HasMany(e => e.Task)
                .WithRequired(e => e.Person)
                .HasForeignKey(e => e.AcceptedTaskId)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<Person>()
                .HasMany(e => e.Task1)
                .WithRequired(e => e.Person1)
                .HasForeignKey(e => e.CreaterTaskId)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<StatusTask>()
                .HasMany(e => e.Task)
                .WithRequired(e => e.StatusTask)
                .WillCascadeOnDelete(false);
        }
    }
}
