问题
I'm getting this error when I try to change column value.
Here is how I got to this problem:
1) I was needed to add this bit column to an Existing table.
ALTER TABLE BooksDB.dbo.Books
ADD edited bit NOT NULL DEFAULT(0),
2) Updated my EF model in project.
3) Now when I try to change 'edited' property of entity object, I'm getting the error from Subject line.
Why is that?
EF object declaration:
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Boolean edited
{
get
{
return _edited;
}
set
{
if (_edited != value)
{
OneditedChanging(value);
ReportPropertyChanging("edited");
_edited = StructuralObject.SetValidValue(value);
ReportPropertyChanged("edited");
OneditedChanged();
}
}
}
private global::System.Boolean _edited;
partial void OneditedChanging(global::System.Boolean value);
partial void OneditedChanged();
回答1:
This problem solved by adding PRIMARY KEY to the table.
来源:https://stackoverflow.com/questions/17519848/invalidoperationexception-the-property-is-part-of-the-objects-key-information