【发布时间】:2010-02-03 08:21:39
【问题描述】:
我的数据库中有一个名为CompanyDetails 的表。它有一个名为CharacterID varchar(255) 的列。我只是将它从 NOT NULL 列更改为 NULL 列。我在模型浏览器和 EDMX 文件查看器中运行了“从数据库更新模型...”命令。这是它在设计器中创建的:
/// <summary>
/// There are no comments for Property CharacterId in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public string CharacterId
{
get
{
return this._CharacterId;
}
set
{
this.OnCharacterIdChanging(value);
this.ReportPropertyChanging("CharacterId");
this._CharacterId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
this.ReportPropertyChanged("CharacterId");
this.OnCharacterIdChanged();
}
}
private string _CharacterId;
partial void OnCharacterIdChanging(string value);
partial void OnCharacterIdChanged();
/// <summary>
/// There are no comments for Property URLDomain in the schema.
/// </summary>
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public string URLDomain
{
get
{
return this._URLDomain;
}
set
{
this.OnURLDomainChanging(value);
this.ReportPropertyChanging("URLDomain");
this._URLDomain = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
this.ReportPropertyChanged("URLDomain");
this.OnURLDomainChanged();
}
}
private string _URLDomain;
partial void OnURLDomainChanging(string value);
partial void OnURLDomainChanged();
你会注意到它有一个属性:
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
我还包括了下一个属性,您会注意到它被正确标记为:
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
什么给了?如何在我的数据库架构中进行简单的更改,并真正让实体框架根据这些更改进行更新?!每次发生变化时,我都不得不删除并重新创建模型!
【问题讨论】:
标签: .net entity-framework updatemodel