我的数据库中有一张名为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()]
是什么赋予了?如何在我的数据库架构中进行简单的更改,并真正让实体框架根据这些更改进行更新?!每次发生变化时,我都不得不放弃并重新创建模型!