I have two classes university and department, suppose there is one to many relationship i.e one university has many departments
public class University
{
public string UniversityId;
public string UniversityName;
public List<Department> Departments;
}
public class Department
{
public string DepartmentId;
public string DepartmentName;
}
I want to map this relationship using Entity framework data annotation feature ctp5 and also can someone point me to any good tutorial of data annotation features
See this http://blogs.msdn.com/b/efdesign/archive/2010/06/01/conventions-for-code-first.aspx Euphoric is correct you do not need annotations. However if you want to have multiple relationships between objects you may need to use the fluent API.
So the only code you would need is
public class University
{
public string UniversityId { get; set; }
public string UniversityName { get; set; }
public List<Department> Departments { get; set; }
}
public class Department
{
public string DepartmentId { get; set; }
public string DepartmentName { get; set; }
public University University{ get; set; }
}