我正在开发一个 asp.net mvc-4 web 应用程序。我正在使用 Entity Framework 5。我使用 EF 映射了我的数据库表。
现在我曾经在我的 .tt 文件夹中有以下模型类:-
public partial class CustomAsset
{
public string CustomerName { get; set; }
public int CustomTypeID { get; set; }
public string Description { get; set; }
public int ID { get; set; }
public int Quantity { get; set; }
public virtual CustomAssetType CustomAssetType { get; set; }
}
现在在名为“customAsset”的数据库表中,我删除了该CustomerName
列。我添加了两列,其中一列是另一个表的外键。然后我打开我的 .edmx 文件我右键单击,然后我选择从数据库中更新模型,在那里我选择 realted 表并单击更新。现在 .edmx 文件中的模型正确地获得了新的列/关系,如下所示:-
但我相关的 .tt 类仍在引用旧列。我期待我的 .tt 模型类如下:-
public partial class CustomAsset
{
//public string CustomerName { get; set; }
public int CustomTypeID { get; set; }
public string Description { get; set; }
public int ID { get; set; }
public int Quantity { get; set; }
public int? CustomerID { get; set; }
public int? RackID { get; set; }
public virtual CustomAssetType CustomAssetType { get; set; }
public virtual Rack Rack { get; set; }
}
所以不确定当我更新 .edmx 文件时如何强制我的 .tt 类更新?如果我手动修改相关的 .tt 类以获取新的列/关系,是否有任何问题?