I have a table in my DB called CompanyDetails
. It has a column called CharacterID varchar(255)
. I just changed it from a NOT NULL
column to a NULL
column. I ran the 'Update Model From Database...' command in the model browser as well as in the EDMX file viewer. This is what it created in the designer:
/// <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();
You will notice that it has an attribute of:
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
I also included the next property and you will notice that it is correctly marked as:
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
What gives? How can I make simple changes in my DB schema and really get the Entity Framework to Update based on those changes?! I've had to drop and recreate the model each and everytime there was a change!