Model Class: DepartmentInfo.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using SnapObjects.Data;
using Newtonsoft.Json;
namespace Appeon.ApiDoc.Models.School
{
[Table("Department", Schema = "dbo")]
[UpdateWhereStrategy(UpdateWhereStrategy.KeyColumns)]
public class DepartmentInfo
{
[Key]
public Int32 DepartmentID { get; set; }
public String Name { get; set; }
public Decimal Budget { get; set; }
public DateTime StartDate { get; set; }
public Int32? Administrator { get; set; }
[JsonIgnore]
[SetValue("$DepartmentID", "$DepartmentID", SetValueStrategy.Always)]
[ModelEmbedded(typeof(CourseInfo), ParamValue = "$DepartmentID",
CascadeCreate = true, CascadeDelete = true)]
public IList<CourseInfo> Courses { get; set; }
}
}