This problem solved by adding PRIMARY KEY to the table.
InvalidOperationException: The property is part of the object's key information and cannot be modified
-
02-06-2022 - |
Vra
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();
Oplossing
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow