C# 从局部视图获取模型数据

C# 从局部视图获取模型数据,c#,javascript,asp.net-mvc,jquery,asp.net-mvc-partialview,C#,Javascript,Asp.net Mvc,Jquery,Asp.net Mvc Partialview,我正在使用MVC体系结构和实体框架(数据库优先)开发一个intranet ASP web应用程序。我的问题如下: 我有一个实体“Person”和一个实体“PhoneCard”,其中包括一个外键“Person”(即Id_Person)的主键。我使用实体框架创建了一个CRUD控制器“PersonController”,VisualStudio已经自动生成了相应的视图(索引、详细信息、创建、编辑和删除)。然后,我创建了另一个CRUD控制器(始终使用EF),名为“PhoneCardController”

我正在使用MVC体系结构和实体框架(数据库优先)开发一个intranet ASP web应用程序。我的问题如下:

我有一个实体“Person”和一个实体“PhoneCard”,其中包括一个外键“Person”(即Id_Person)的主键。我使用实体框架创建了一个CRUD控制器“PersonController”,VisualStudio已经自动生成了相应的视图(索引、详细信息、创建、编辑和删除)。然后,我创建了另一个CRUD控制器(始终使用EF),名为“PhoneCardController”。在我的CreatePerson视图中,由于AJAX功能,我包含了CreatePhoneCard视图:

function addPhoneCardCreateView() {

    $('#divCreatePhoneCard').load("@Url.Action("Create","PhoneCard")");

}
这样称呼它:

<a href = "javascript:addPhoneCardCreateView()">Add a Phone card</a>
    <div id = "divCreatePhoneCard"></div>
我的部分观点是:

@model BuSIMaterial.Models.PhoneCard

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Create</title>
</head>
<body>
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>PhoneCard</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.PhoneNumber)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PhoneNumber)
                @Html.ValidationMessageFor(model => model.PhoneNumber)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.SimNumber)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.SimNumber)
                @Html.ValidationMessageFor(model => model.SimNumber)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.PIN)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PIN)
                @Html.ValidationMessageFor(model => model.PIN)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.PIN2)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PIN2)
                @Html.ValidationMessageFor(model => model.PIN2)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.PUK)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PUK)
                @Html.ValidationMessageFor(model => model.PUK)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.PUK2)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PUK2)
                @Html.ValidationMessageFor(model => model.PUK2)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Id_Person, "Person")
            </div>
            <div class="editor-field">
                @Html.DropDownList("Id_Person", String.Empty)
                @Html.ValidationMessageFor(model => model.Id_Person)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Id_PhoneSubscription, "PhoneSubscription")
            </div>
            <div class="editor-field">
                @Html.DropDownList("Id_PhoneSubscription", String.Empty)
                @Html.ValidationMessageFor(model => model.Id_PhoneSubscription)
            </div>
        </fieldset>
    }

</body>
</html>
@model.Models.PhoneCard
@{
布局=空;
}
创造
@使用(Html.BeginForm()){
@Html.ValidationSummary(true)
电话卡
@LabelFor(model=>model.PhoneNumber)
@EditorFor(model=>model.PhoneNumber)
@Html.ValidationMessageFor(model=>model.PhoneNumber)
@LabelFor(model=>model.SimNumber)
@EditorFor(model=>model.SimNumber)
@Html.ValidationMessageFor(model=>model.SimNumber)
@LabelFor(model=>model.PIN)
@EditorFor(model=>model.PIN)
@Html.ValidationMessageFor(model=>model.PIN)
@LabelFor(model=>model.PIN2)
@EditorFor(model=>model.PIN2)
@Html.ValidationMessageFor(model=>model.PIN2)
@LabelFor(model=>model.PUK)
@EditorFor(model=>model.PUK)
@Html.ValidationMessageFor(model=>model.PUK)
@LabelFor(model=>model.PUK2)
@EditorFor(model=>model.PUK2)
@Html.ValidationMessageFor(model=>model.PUK2)
@Html.LabelFor(model=>model.Id\u Person,“Person”)
@Html.DropDownList(“Id_Person”,String.Empty)
@Html.ValidationMessageFor(model=>model.Id\u Person)
@LabelFor(model=>model.Id\u PhoneSubscription,“PhoneSubscription”)
@DropDownList(“Id\u PhoneSubscription”,String.Empty)
@Html.ValidationMessageFor(model=>model.Id\u电话订阅)
}
人物模型:

[EdmEntityTypeAttribute(NamespaceName="BuSIMaterialModel", Name="Person")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Person : EntityObject
{
    #region Factory Method

    /// <summary>
    /// Create a new Person object.
    /// </summary>
    /// <param name="id_Person">Initial value of the Id_Person property.</param>
    /// <param name="firstName">Initial value of the FirstName property.</param>
    /// <param name="lastName">Initial value of the LastName property.</param>
    /// <param name="numNat">Initial value of the NumNat property.</param>
    /// <param name="startDate">Initial value of the StartDate property.</param>
    /// <param name="upgrade">Initial value of the Upgrade property.</param>
    /// <param name="id_ProductPackageCategory">Initial value of the Id_ProductPackageCategory property.</param>
    /// <param name="houseToWorkKilometers">Initial value of the HouseToWorkKilometers property.</param>
    public static Person CreatePerson(global::System.Int64 id_Person, global::System.String firstName, global::System.String lastName, global::System.String numNat, global::System.DateTime startDate, global::System.Boolean upgrade, global::System.Int64 id_ProductPackageCategory, global::System.Decimal houseToWorkKilometers)
    {
        Person person = new Person();
        person.Id_Person = id_Person;
        person.FirstName = firstName;
        person.LastName = lastName;
        person.NumNat = numNat;
        person.StartDate = startDate;
        person.Upgrade = upgrade;
        person.Id_ProductPackageCategory = id_ProductPackageCategory;
        person.HouseToWorkKilometers = houseToWorkKilometers;
        return person;
    }

    #endregion
    #region Primitive Properties

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int64 Id_Person
    {
        get
        {
            return _Id_Person;
        }
        set
        {
            if (_Id_Person != value)
            {
                OnId_PersonChanging(value);
                ReportPropertyChanging("Id_Person");
                _Id_Person = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Id_Person");
                OnId_PersonChanged();
            }
        }
    }
    private global::System.Int64 _Id_Person;
    partial void OnId_PersonChanging(global::System.Int64 value);
    partial void OnId_PersonChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    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()]
    [Required]
    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();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    public global::System.String NumNat
    {
        get
        {
            return _NumNat;
        }
        set
        {
            OnNumNatChanging(value);
            ReportPropertyChanging("NumNat");
            _NumNat = StructuralObject.SetValidValue(value, false);
            ReportPropertyChanged("NumNat");
            OnNumNatChanged();
        }
    }
    private global::System.String _NumNat;
    partial void OnNumNatChanging(global::System.String value);
    partial void OnNumNatChanged();

    /// <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();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
    [DataMemberAttribute()]
    public Nullable<global::System.DateTime> EndDate
    {
        get
        {
            return _EndDate;
        }
        set
        {
            OnEndDateChanging(value);
            ReportPropertyChanging("EndDate");
            _EndDate = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("EndDate");
            OnEndDateChanged();
        }
    }
    private Nullable<global::System.DateTime> _EndDate;
    partial void OnEndDateChanging(Nullable<global::System.DateTime> value);
    partial void OnEndDateChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Boolean Upgrade
    {
        get
        {
            return _Upgrade;
        }
        set
        {
            OnUpgradeChanging(value);
            ReportPropertyChanging("Upgrade");
            _Upgrade = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("Upgrade");
            OnUpgradeChanged();
        }
    }
    private global::System.Boolean _Upgrade;
    partial void OnUpgradeChanging(global::System.Boolean value);
    partial void OnUpgradeChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    public global::System.Int64 Id_ProductPackageCategory
    {
        get
        {
            return _Id_ProductPackageCategory;
        }
        set
        {
            OnId_ProductPackageCategoryChanging(value);
            ReportPropertyChanging("Id_ProductPackageCategory");
            _Id_ProductPackageCategory = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("Id_ProductPackageCategory");
            OnId_ProductPackageCategoryChanged();
        }
    }
    private global::System.Int64 _Id_ProductPackageCategory;
    partial void OnId_ProductPackageCategoryChanging(global::System.Int64 value);
    partial void OnId_ProductPackageCategoryChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Decimal HouseToWorkKilometers
    {
        get
        {
            return _HouseToWorkKilometers;
        }
        set
        {
            OnHouseToWorkKilometersChanging(value);
            ReportPropertyChanging("HouseToWorkKilometers");
            _HouseToWorkKilometers = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("HouseToWorkKilometers");
            OnHouseToWorkKilometersChanged();
        }
    }
    private global::System.Decimal _HouseToWorkKilometers;
    partial void OnHouseToWorkKilometersChanging(global::System.Decimal value);
    partial void OnHouseToWorkKilometersChanged();

    #endregion

    #region Navigation Properties

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories")]
    public ProductPackageCategory ProductPackageCategory
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories").Value;
        }
        set
        {
            ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories").Value = value;
        }
    }
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [BrowsableAttribute(false)]
    [DataMemberAttribute()]
    public EntityReference<ProductPackageCategory> ProductPackageCategoryReference
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards")]
    public EntityCollection<PhoneCard> PhoneCards
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<PhoneCard>("BuSIMaterialModel.FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<PhoneCard>("BuSIMaterialModel.FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations")]
    public EntityCollection<ProductAllocation> ProductAllocations
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<ProductAllocation>("BuSIMaterialModel.FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<ProductAllocation>("BuSIMaterialModel.FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards")]
    public EntityCollection<VehicleFuelCard> VehicleFuelCards
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<VehicleFuelCard>("BuSIMaterialModel.FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<VehicleFuelCard>("BuSIMaterialModel.FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards", value);
            }
        }
    }

    #endregion
}
[EdmEntityTypeAttribute(NamespaceName=“BuSIMaterialModel”,Name=“Person”)]
[可序列化()]
[DataContractAttribute(IsReference=true)]
公共部分类Person:EntityObject
{
#区域工厂法
/// 
///创建一个新的Person对象。
/// 
///Id_Person属性的初始值。
///FirstName属性的初始值。
///LastName属性的初始值。
///NumNat属性的初始值。
///StartDate属性的初始值。
///升级属性的初始值。
///Id_ProductPackageCategory属性的初始值。
///HouseToworkkm属性的初始值。
公共静态Person CreatePerson(全局::System.Int64 id_Person,全局::System.String firstName,全局::System.String lastName,全局::System.String numNat,全局::System.DateTime startDate,全局::System.Boolean upgrade,全局::System.Int64 id_ProductPackageCategory,全局::System.Decimal House ToWorkKm)
{
Person=新人();
person.Id\u person=Id\u person;
person.FirstName=FirstName;
person.LastName=LastName;
person.NumNat=NumNat;
person.StartDate=StartDate;
person.Upgrade=升级;
person.Id\u ProductPackageCategory=Id\u ProductPackageCategory;
person.houseToworkkm=houseToworkkm;
返回人;
}
#端区
#区域基本属性
/// 
///没有可用的元数据文档。
/// 
[EdmScalarPropertyAttribute(EntityKeyProperty=true,IsNullable=false)]
[DataMemberAttribute()]
public global::System.Int64 Id\u Person
{
得到
{
返回(身份)人;;
}
设置
{
如果(\u Id\u Person!=值)
{
OnId_人员变更(价值);
报告财产变更(“身份证持有人”);
_Id_Person=StructuralObject.SetValidValue(值);
报告财产变更(“身份证持有人”);
只有一个人改变了;
}
}
}
私有全局::System.Int64_Id_Person;
部分无效OnId_PersonChange(全局::System.Int64值);
部分无效OnId_PersonChanged();
/// 
///没有可用的元数据文档。
/// 
[EdmScalarPropertyAttribute(EntityKeyProperty=false,IsNullable=false)]
[DataMemberAttribute()]
[必需]
public global::System.String FirstName
{
得到
{
返回_FirstName;
}
设置
{
onfirstNameChanged(值);
报告财产变更(“名字”);
_FirstName=StructuralObject.SetValidValue(值,false);
报告财产变更(“名字”);
OnFirstNameChanged();
}
}
私有全局::System.String_FirstName;
部分无效OnFirstNameChanging(全局::System.String值);
部分无效OnFirstNameChanged();
/// 
///没有可用的元数据文档。
/// 
[EdmScalarPropertyAttribute(EntityKeyProperty=f
[EdmEntityTypeAttribute(NamespaceName="BuSIMaterialModel", Name="Person")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Person : EntityObject
{
    #region Factory Method

    /// <summary>
    /// Create a new Person object.
    /// </summary>
    /// <param name="id_Person">Initial value of the Id_Person property.</param>
    /// <param name="firstName">Initial value of the FirstName property.</param>
    /// <param name="lastName">Initial value of the LastName property.</param>
    /// <param name="numNat">Initial value of the NumNat property.</param>
    /// <param name="startDate">Initial value of the StartDate property.</param>
    /// <param name="upgrade">Initial value of the Upgrade property.</param>
    /// <param name="id_ProductPackageCategory">Initial value of the Id_ProductPackageCategory property.</param>
    /// <param name="houseToWorkKilometers">Initial value of the HouseToWorkKilometers property.</param>
    public static Person CreatePerson(global::System.Int64 id_Person, global::System.String firstName, global::System.String lastName, global::System.String numNat, global::System.DateTime startDate, global::System.Boolean upgrade, global::System.Int64 id_ProductPackageCategory, global::System.Decimal houseToWorkKilometers)
    {
        Person person = new Person();
        person.Id_Person = id_Person;
        person.FirstName = firstName;
        person.LastName = lastName;
        person.NumNat = numNat;
        person.StartDate = startDate;
        person.Upgrade = upgrade;
        person.Id_ProductPackageCategory = id_ProductPackageCategory;
        person.HouseToWorkKilometers = houseToWorkKilometers;
        return person;
    }

    #endregion
    #region Primitive Properties

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int64 Id_Person
    {
        get
        {
            return _Id_Person;
        }
        set
        {
            if (_Id_Person != value)
            {
                OnId_PersonChanging(value);
                ReportPropertyChanging("Id_Person");
                _Id_Person = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Id_Person");
                OnId_PersonChanged();
            }
        }
    }
    private global::System.Int64 _Id_Person;
    partial void OnId_PersonChanging(global::System.Int64 value);
    partial void OnId_PersonChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    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()]
    [Required]
    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();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    public global::System.String NumNat
    {
        get
        {
            return _NumNat;
        }
        set
        {
            OnNumNatChanging(value);
            ReportPropertyChanging("NumNat");
            _NumNat = StructuralObject.SetValidValue(value, false);
            ReportPropertyChanged("NumNat");
            OnNumNatChanged();
        }
    }
    private global::System.String _NumNat;
    partial void OnNumNatChanging(global::System.String value);
    partial void OnNumNatChanged();

    /// <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();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
    [DataMemberAttribute()]
    public Nullable<global::System.DateTime> EndDate
    {
        get
        {
            return _EndDate;
        }
        set
        {
            OnEndDateChanging(value);
            ReportPropertyChanging("EndDate");
            _EndDate = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("EndDate");
            OnEndDateChanged();
        }
    }
    private Nullable<global::System.DateTime> _EndDate;
    partial void OnEndDateChanging(Nullable<global::System.DateTime> value);
    partial void OnEndDateChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Boolean Upgrade
    {
        get
        {
            return _Upgrade;
        }
        set
        {
            OnUpgradeChanging(value);
            ReportPropertyChanging("Upgrade");
            _Upgrade = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("Upgrade");
            OnUpgradeChanged();
        }
    }
    private global::System.Boolean _Upgrade;
    partial void OnUpgradeChanging(global::System.Boolean value);
    partial void OnUpgradeChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    [Required]
    public global::System.Int64 Id_ProductPackageCategory
    {
        get
        {
            return _Id_ProductPackageCategory;
        }
        set
        {
            OnId_ProductPackageCategoryChanging(value);
            ReportPropertyChanging("Id_ProductPackageCategory");
            _Id_ProductPackageCategory = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("Id_ProductPackageCategory");
            OnId_ProductPackageCategoryChanged();
        }
    }
    private global::System.Int64 _Id_ProductPackageCategory;
    partial void OnId_ProductPackageCategoryChanging(global::System.Int64 value);
    partial void OnId_ProductPackageCategoryChanged();

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Decimal HouseToWorkKilometers
    {
        get
        {
            return _HouseToWorkKilometers;
        }
        set
        {
            OnHouseToWorkKilometersChanging(value);
            ReportPropertyChanging("HouseToWorkKilometers");
            _HouseToWorkKilometers = StructuralObject.SetValidValue(value);
            ReportPropertyChanged("HouseToWorkKilometers");
            OnHouseToWorkKilometersChanged();
        }
    }
    private global::System.Decimal _HouseToWorkKilometers;
    partial void OnHouseToWorkKilometersChanging(global::System.Decimal value);
    partial void OnHouseToWorkKilometersChanged();

    #endregion

    #region Navigation Properties

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories")]
    public ProductPackageCategory ProductPackageCategory
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories").Value;
        }
        set
        {
            ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories").Value = value;
        }
    }
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [BrowsableAttribute(false)]
    [DataMemberAttribute()]
    public EntityReference<ProductPackageCategory> ProductPackageCategoryReference
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<ProductPackageCategory>("BuSIMaterialModel.FK_bm_Persons_bm_ProductPackageCategories", "bm_ProductPackageCategories", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards")]
    public EntityCollection<PhoneCard> PhoneCards
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<PhoneCard>("BuSIMaterialModel.FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<PhoneCard>("BuSIMaterialModel.FK_bm_PhoneCards_bm_Persons", "bm_PhoneCards", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations")]
    public EntityCollection<ProductAllocation> ProductAllocations
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<ProductAllocation>("BuSIMaterialModel.FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<ProductAllocation>("BuSIMaterialModel.FK_bm_ProductAllocations_bm_Persons", "bm_ProductAllocations", value);
            }
        }
    }

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("BuSIMaterialModel", "FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards")]
    public EntityCollection<VehicleFuelCard> VehicleFuelCards
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<VehicleFuelCard>("BuSIMaterialModel.FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<VehicleFuelCard>("BuSIMaterialModel.FK_bm_VehicleFuelCards_bm_Persons", "bm_VehicleFuelCards", value);
            }
        }
    }

    #endregion
}