EF4 Model First feature demo (CSEFModelFirst)

This example illustrates how to use the new feature - Model First - in the ADO.NET Entity Framework 4.0 to generate DDL that will create a database according to the Entity Data Model.

C# (56.1 KB)
 
 
 
 
 
4 Star
(1)
11,515 times
Add to favorites
5/5/2011
E-mail Twitter del.icio.us Digg Facebook
//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata

[assembly: EdmRelationshipAttribute("ModelFirst", "DepartmentCourse", "Department", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(CSEFModelFirst.Department), "Course", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(CSEFModelFirst.Course), true)]
[assembly: EdmRelationshipAttribute("ModelFirst", "CourseInstructor", "Course", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(CSEFModelFirst.Course), "Instructor", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(CSEFModelFirst.Instructor))]
[assembly: EdmRelationshipAttribute("ModelFirst", "StudentCourseStudent", "Student", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(CSEFModelFirst.Student), "CourseStudent", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(CSEFModelFirst.CourseStudent), true)]
[assembly: EdmRelationshipAttribute("ModelFirst", "CourseCourseStudent", "Course", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(CSEFModelFirst.Course), "CourseStudent", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(CSEFModelFirst.CourseStudent), true)]

#endregion

namespace CSEFModelFirst
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class ModelFirstContainer : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new ModelFirstContainer object using the connection string found in the 'ModelFirstContainer' section of the application configuration file.
        /// </summary>
        public ModelFirstContainer() : base("name=ModelFirstContainer", "ModelFirstContainer")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ModelFirstContainer object.
        /// </summary>
        public ModelFirstContainer(string connectionString) : base(connectionString, "ModelFirstContainer")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ModelFirstContainer object.
        /// </summary>
        public ModelFirstContainer(EntityConnection connection) : base(connection, "ModelFirstContainer")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Person> People
        {
            get
            {
                if ((_People == null))
                {
                    _People = base.CreateObjectSet<Person>("People");
                }
                return _People;
            }
        }
        private ObjectSet<Person> _People;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Course> Courses
        {
            get
            {
                if ((_Courses == null))
                {
                    _Courses = base.CreateObjectSet<Course>("Courses");
                }
                return _Courses;
            }
        }
        private ObjectSet<Course> _Courses;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Department> Departments
        {
            get
            {
                if ((_Departments == null))
                {
                    _Departments = base.CreateObjectSet<Department>("Departments");
                }
                return _Departments;
            }
        }
        private ObjectSet<Department> _Departments;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<CourseStudent> CourseStudents
        {
            get
            {
                if ((_CourseStudents == null))
                {
                    _CourseStudents = base.CreateObjectSet<CourseStudent>("CourseStudents");
                }
                return _CourseStudents;
            }
        }
        private ObjectSet<CourseStudent> _CourseStudents;

        #endregion
        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the People EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToPeople(Person person)
        {
            base.AddObject("People", person);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Courses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToCourses(Course course)
        {
            base.AddObject("Courses", course);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Departments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToDepartments(Department department)
        {
            base.AddObject("Departments", department);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the CourseStudents EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToCourseStudents(CourseStudent courseStudent)
        {
            base.AddObject("CourseStudents", courseStudent);
        }

        #endregion
    }
    

    #endregion
    
    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Admin")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Admin : Person
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Admin object.
        /// </summary>
        /// <param name="personID">Initial value of the PersonID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="address">Initial value of the Address property.</param>
        /// <param name="adminDate">Initial value of the AdminDate property.</param>
        public static Admin CreateAdmin(global::System.Int32 personID, Name name, Address address, global::System.DateTime adminDate)
        {
            Admin admin = new Admin();
            admin.PersonID = personID;
            admin.Name = StructuralObject.VerifyComplexObjectIsNotNull(name, "Name");
            admin.Address = StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
            admin.AdminDate = adminDate;
            return admin;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime AdminDate
        {
            get
            {
                return _AdminDate;
            }
            set
            {
                OnAdminDateChanging(value);
                ReportPropertyChanging("AdminDate");
                _AdminDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("AdminDate");
                OnAdminDateChanged();
            }
        }
        private global::System.DateTime _AdminDate;
        partial void OnAdminDateChanging(global::System.DateTime value);
        partial void OnAdminDateChanged();

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="BusinessStudent")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class BusinessStudent : Student
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new BusinessStudent object.
        /// </summary>
        /// <param name="personID">Initial value of the PersonID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="address">Initial value of the Address property.</param>
        /// <param name="enrollmentDate">Initial value of the EnrollmentDate property.</param>
        public static BusinessStudent CreateBusinessStudent(global::System.Int32 personID, Name name, Address address, global::System.DateTime enrollmentDate)
        {
            BusinessStudent businessStudent = new BusinessStudent();
            businessStudent.PersonID = personID;
            businessStudent.Name = StructuralObject.VerifyComplexObjectIsNotNull(name, "Name");
            businessStudent.Address = StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
            businessStudent.EnrollmentDate = enrollmentDate;
            return businessStudent;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> BusinessCredits
        {
            get
            {
                return _BusinessCredits;
            }
            set
            {
                OnBusinessCreditsChanging(value);
                ReportPropertyChanging("BusinessCredits");
                _BusinessCredits = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("BusinessCredits");
                OnBusinessCreditsChanged();
            }
        }
        private Nullable<global::System.Int32> _BusinessCredits;
        partial void OnBusinessCreditsChanging(Nullable<global::System.Int32> value);
        partial void OnBusinessCreditsChanged();

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Course")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Course : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Course object.
        /// </summary>
        /// <param name="courseID">Initial value of the CourseID property.</param>
        /// <param name="title">Initial value of the Title property.</param>
        /// <param name="credits">Initial value of the Credits property.</param>
        /// <param name="departmentID">Initial value of the DepartmentID property.</param>
        public static Course CreateCourse(global::System.Int32 courseID, global::System.String title, global::System.Int32 credits, global::System.Int32 departmentID)
        {
            Course course = new Course();
            course.CourseID = courseID;
            course.Title = title;
            course.Credits = credits;
            course.DepartmentID = departmentID;
            return course;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 CourseID
        {
            get
            {
                return _CourseID;
            }
            set
            {
                if (_CourseID != value)
                {
                    OnCourseIDChanging(value);
                    ReportPropertyChanging("CourseID");
                    _CourseID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("CourseID");
                    OnCourseIDChanged();
                }
            }
        }
        private global::System.Int32 _CourseID;
        partial void OnCourseIDChanging(global::System.Int32 value);
        partial void OnCourseIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Title
        {
            get
            {
                return _Title;
            }
            set
            {
                OnTitleChanging(value);
                ReportPropertyChanging("Title");
                _Title = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Title");
                OnTitleChanged();
            }
        }
        private global::System.String _Title;
        partial void OnTitleChanging(global::System.String value);
        partial void OnTitleChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Credits
        {
            get
            {
                return _Credits;
            }
            set
            {
                OnCreditsChanging(value);
                ReportPropertyChanging("Credits");
                _Credits = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Credits");
                OnCreditsChanged();
            }
        }
        private global::System.Int32 _Credits;
        partial void OnCreditsChanging(global::System.Int32 value);
        partial void OnCreditsChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 DepartmentID
        {
            get
            {
                return _DepartmentID;
            }
            set
            {
                OnDepartmentIDChanging(value);
                ReportPropertyChanging("DepartmentID");
                _DepartmentID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("DepartmentID");
                OnDepartmentIDChanged();
            }
        }
        private global::System.Int32 _DepartmentID;
        partial void OnDepartmentIDChanging(global::System.Int32 value);
        partial void OnDepartmentIDChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "DepartmentCourse", "Department")]
        public Department Department
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Department>("ModelFirst.DepartmentCourse", "Department").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Department>("ModelFirst.DepartmentCourse", "Department").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Department> DepartmentReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Department>("ModelFirst.DepartmentCourse", "Department");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Department>("ModelFirst.DepartmentCourse", "Department", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "CourseInstructor", "Instructor")]
        public EntityCollection<Instructor> Instructors
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Instructor>("ModelFirst.CourseInstructor", "Instructor");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Instructor>("ModelFirst.CourseInstructor", "Instructor", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "CourseCourseStudent", "CourseStudent")]
        public EntityCollection<CourseStudent> CourseStudents
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<CourseStudent>("ModelFirst.CourseCourseStudent", "CourseStudent");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<CourseStudent>("ModelFirst.CourseCourseStudent", "CourseStudent", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="CourseStudent")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class CourseStudent : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new CourseStudent object.
        /// </summary>
        /// <param name="personID">Initial value of the PersonID property.</param>
        /// <param name="courseID">Initial value of the CourseID property.</param>
        public static CourseStudent CreateCourseStudent(global::System.Int32 personID, global::System.Int32 courseID)
        {
            CourseStudent courseStudent = new CourseStudent();
            courseStudent.PersonID = personID;
            courseStudent.CourseID = courseID;
            return courseStudent;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 PersonID
        {
            get
            {
                return _PersonID;
            }
            set
            {
                if (_PersonID != value)
                {
                    OnPersonIDChanging(value);
                    ReportPropertyChanging("PersonID");
                    _PersonID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("PersonID");
                    OnPersonIDChanged();
                }
            }
        }
        private global::System.Int32 _PersonID;
        partial void OnPersonIDChanging(global::System.Int32 value);
        partial void OnPersonIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 CourseID
        {
            get
            {
                return _CourseID;
            }
            set
            {
                if (_CourseID != value)
                {
                    OnCourseIDChanging(value);
                    ReportPropertyChanging("CourseID");
                    _CourseID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("CourseID");
                    OnCourseIDChanged();
                }
            }
        }
        private global::System.Int32 _CourseID;
        partial void OnCourseIDChanging(global::System.Int32 value);
        partial void OnCourseIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> Score
        {
            get
            {
                return _Score;
            }
            set
            {
                OnScoreChanging(value);
                ReportPropertyChanging("Score");
                _Score = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Score");
                OnScoreChanged();
            }
        }
        private Nullable<global::System.Int32> _Score;
        partial void OnScoreChanging(Nullable<global::System.Int32> value);
        partial void OnScoreChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "StudentCourseStudent", "Student")]
        public Student Student
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Student>("ModelFirst.StudentCourseStudent", "Student").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Student>("ModelFirst.StudentCourseStudent", "Student").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Student> StudentReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Student>("ModelFirst.StudentCourseStudent", "Student");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Student>("ModelFirst.StudentCourseStudent", "Student", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "CourseCourseStudent", "Course")]
        public Course Course
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Course>("ModelFirst.CourseCourseStudent", "Course").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Course>("ModelFirst.CourseCourseStudent", "Course").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Course> CourseReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Course>("ModelFirst.CourseCourseStudent", "Course");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Course>("ModelFirst.CourseCourseStudent", "Course", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Department")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Department : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Department object.
        /// </summary>
        /// <param name="departmentID">Initial value of the DepartmentID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="startDate">Initial value of the StartDate property.</param>
        public static Department CreateDepartment(global::System.Int32 departmentID, global::System.String name, global::System.DateTime startDate)
        {
            Department department = new Department();
            department.DepartmentID = departmentID;
            department.Name = name;
            department.StartDate = startDate;
            return department;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 DepartmentID
        {
            get
            {
                return _DepartmentID;
            }
            set
            {
                if (_DepartmentID != value)
                {
                    OnDepartmentIDChanging(value);
                    ReportPropertyChanging("DepartmentID");
                    _DepartmentID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("DepartmentID");
                    OnDepartmentIDChanged();
                }
            }
        }
        private global::System.Int32 _DepartmentID;
        partial void OnDepartmentIDChanging(global::System.Int32 value);
        partial void OnDepartmentIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                OnNameChanging(value);
                ReportPropertyChanging("Name");
                _Name = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Name");
                OnNameChanged();
            }
        }
        private global::System.String _Name;
        partial void OnNameChanging(global::System.String value);
        partial void OnNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> Budget
        {
            get
            {
                return _Budget;
            }
            set
            {
                OnBudgetChanging(value);
                ReportPropertyChanging("Budget");
                _Budget = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Budget");
                OnBudgetChanged();
            }
        }
        private Nullable<global::System.Decimal> _Budget;
        partial void OnBudgetChanging(Nullable<global::System.Decimal> value);
        partial void OnBudgetChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime StartDate
        {
            get
            {
                return _StartDate;
            }
            set
            {
                OnStartDateChanging(value);
                ReportPropertyChanging("StartDate");
                _StartDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("StartDate");
                OnStartDateChanged();
            }
        }
        private global::System.DateTime _StartDate;
        partial void OnStartDateChanging(global::System.DateTime value);
        partial void OnStartDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "DepartmentCourse", "Course")]
        public EntityCollection<Course> Courses
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Course>("ModelFirst.DepartmentCourse", "Course");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Course>("ModelFirst.DepartmentCourse", "Course", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Instructor")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Instructor : Person
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Instructor object.
        /// </summary>
        /// <param name="personID">Initial value of the PersonID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="address">Initial value of the Address property.</param>
        /// <param name="hireDate">Initial value of the HireDate property.</param>
        public static Instructor CreateInstructor(global::System.Int32 personID, Name name, Address address, global::System.DateTime hireDate)
        {
            Instructor instructor = new Instructor();
            instructor.PersonID = personID;
            instructor.Name = StructuralObject.VerifyComplexObjectIsNotNull(name, "Name");
            instructor.Address = StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
            instructor.HireDate = hireDate;
            return instructor;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime HireDate
        {
            get
            {
                return _HireDate;
            }
            set
            {
                OnHireDateChanging(value);
                ReportPropertyChanging("HireDate");
                _HireDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("HireDate");
                OnHireDateChanged();
            }
        }
        private global::System.DateTime _HireDate;
        partial void OnHireDateChanging(global::System.DateTime value);
        partial void OnHireDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "CourseInstructor", "Course")]
        public EntityCollection<Course> Courses
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Course>("ModelFirst.CourseInstructor", "Course");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Course>("ModelFirst.CourseInstructor", "Course", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Person")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    [KnownTypeAttribute(typeof(Instructor))]
    [KnownTypeAttribute(typeof(Student))]
    [KnownTypeAttribute(typeof(Admin))]
    public abstract partial class Person : EntityObject
    {
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 PersonID
        {
            get
            {
                return _PersonID;
            }
            set
            {
                if (_PersonID != value)
                {
                    OnPersonIDChanging(value);
                    ReportPropertyChanging("PersonID");
                    _PersonID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("PersonID");
                    OnPersonIDChanged();
                }
            }
        }
        private global::System.Int32 _PersonID;
        partial void OnPersonIDChanging(global::System.Int32 value);
        partial void OnPersonIDChanged();

        #endregion
        #region Complex Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmComplexPropertyAttribute()]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [XmlElement(IsNullable=true)]
        [SoapElement(IsNullable=true)]
        [DataMemberAttribute()]
        public Name Name
        {
            get
            {
                _Name = GetValidValue(_Name, "Name", false, _NameInitialized);
                _NameInitialized = true;
                return _Name;
            }
            set
            {
                OnNameChanging(value);
                ReportPropertyChanging("Name");
                _Name = SetValidValue(_Name, value, "Name");
                _NameInitialized = true;
                ReportPropertyChanged("Name");
                OnNameChanged();
            }
        }
        private Name _Name;
        private bool _NameInitialized;
        partial void OnNameChanging(Name value);
        partial void OnNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmComplexPropertyAttribute()]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [XmlElement(IsNullable=true)]
        [SoapElement(IsNullable=true)]
        [DataMemberAttribute()]
        public Address Address
        {
            get
            {
                _Address = GetValidValue(_Address, "Address", false, _AddressInitialized);
                _AddressInitialized = true;
                return _Address;
            }
            set
            {
                OnAddressChanging(value);
                ReportPropertyChanging("Address");
                _Address = SetValidValue(_Address, value, "Address");
                _AddressInitialized = true;
                ReportPropertyChanged("Address");
                OnAddressChanged();
            }
        }
        private Address _Address;
        private bool _AddressInitialized;
        partial void OnAddressChanging(Address value);
        partial void OnAddressChanged();

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ModelFirst", Name="Student")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    [KnownTypeAttribute(typeof(BusinessStudent))]
    public partial class Student : Person
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Student object.
        /// </summary>
        /// <param name="personID">Initial value of the PersonID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="address">Initial value of the Address property.</param>
        /// <param name="enrollmentDate">Initial value of the EnrollmentDate property.</param>
        public static Student CreateStudent(global::System.Int32 personID, Name name, Address address, global::System.DateTime enrollmentDate)
        {
            Student student = new Student();
            student.PersonID = personID;
            student.Name = StructuralObject.VerifyComplexObjectIsNotNull(name, "Name");
            student.Address = StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
            student.EnrollmentDate = enrollmentDate;
            return student;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime EnrollmentDate
        {
            get
            {
                return _EnrollmentDate;
            }
            set
            {
                OnEnrollmentDateChanging(value);
                ReportPropertyChanging("EnrollmentDate");
                _EnrollmentDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("EnrollmentDate");
                OnEnrollmentDateChanged();
            }
        }
        private global::System.DateTime _EnrollmentDate;
        partial void OnEnrollmentDateChanging(global::System.DateTime value);
        partial void OnEnrollmentDateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> Degree
        {
            get
            {
                return _Degree;
            }
            set
            {
                OnDegreeChanging(value);
                ReportPropertyChanging("Degree");
                _Degree = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Degree");
                OnDegreeChanged();
            }
        }
        private Nullable<global::System.Int32> _Degree;
        partial void OnDegreeChanging(Nullable<global::System.Int32> value);
        partial void OnDegreeChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> Credits
        {
            get
            {
                return _Credits;
            }
            set
            {
                OnCreditsChanging(value);
                ReportPropertyChanging("Credits");
                _Credits = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Credits");
                OnCreditsChanged();
            }
        }
        private Nullable<global::System.Int32> _Credits;
        partial void OnCreditsChanging(Nullable<global::System.Int32> value);
        partial void OnCreditsChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ModelFirst", "StudentCourseStudent", "CourseStudent")]
        public EntityCollection<CourseStudent> CourseStudents
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<CourseStudent>("ModelFirst.StudentCourseStudent", "CourseStudent");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<CourseStudent>("ModelFirst.StudentCourseStudent", "CourseStudent", value);
                }
            }
        }

        #endregion
    }

    #endregion
    #region ComplexTypes
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmComplexTypeAttribute(NamespaceName="ModelFirst", Name="Address")]
    [DataContractAttribute(IsReference=true)]
    [Serializable()]
    public partial class Address : ComplexObject
    {
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Country
        {
            get
            {
                return _Country;
            }
            set
            {
                OnCountryChanging(value);
                ReportPropertyChanging("Country");
                _Country = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Country");
                OnCountryChanged();
            }
        }
        private global::System.String _Country;
        partial void OnCountryChanging(global::System.String value);
        partial void OnCountryChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String City
        {
            get
            {
                return _City;
            }
            set
            {
                OnCityChanging(value);
                ReportPropertyChanging("City");
                _City = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("City");
                OnCityChanged();
            }
        }
        private global::System.String _City;
        partial void OnCityChanging(global::System.String value);
        partial void OnCityChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Zipcode
        {
            get
            {
                return _Zipcode;
            }
            set
            {
                OnZipcodeChanging(value);
                ReportPropertyChanging("Zipcode");
                _Zipcode = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Zipcode");
                OnZipcodeChanged();
            }
        }
        private global::System.String _Zipcode;
        partial void OnZipcodeChanging(global::System.String value);
        partial void OnZipcodeChanged();

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmComplexTypeAttribute(NamespaceName="ModelFirst", Name="Name")]
    [DataContractAttribute(IsReference=true)]
    [Serializable()]
    public partial class Name : ComplexObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Name object.
        /// </summary>
        /// <param name="firstName">Initial value of the FirstName property.</param>
        /// <param name="lastName">Initial value of the LastName property.</param>
        public static Name CreateName(global::System.String firstName, global::System.String lastName)
        {
            Name name = new Name();
            name.FirstName = firstName;
            name.LastName = lastName;
            return name;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String FirstName
        {
            get
            {
                return _FirstName;
            }
            set
            {
                OnFirstNameChanging(value);
                ReportPropertyChanging("FirstName");
                _FirstName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("FirstName");
                OnFirstNameChanged();
            }
        }
        private global::System.String _FirstName;
        partial void OnFirstNameChanging(global::System.String value);
        partial void OnFirstNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String LastName
        {
            get
            {
                return _LastName;
            }
            set
            {
                OnLastNameChanging(value);
                ReportPropertyChanging("LastName");
                _LastName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("LastName");
                OnLastNameChanged();
            }
        }
        private global::System.String _LastName;
        partial void OnLastNameChanging(global::System.String value);
        partial void OnLastNameChanged();

        #endregion
    }

    #endregion
    
}