1
Follows the code:
using (var db = new Entities())
{
var t = new MinhaTabela
{
MeuCampo= 10
};
db.Entry(t).State = EntityState.Modified;
db.SaveChanges();
}
Table definition:
CREATE TABLE [dbo].[MinhaTabela] (
[MeuCampo] INT NOT NULL,
CONSTRAINT [PK_MinhaTabela] PRIMARY KEY CLUSTERED ([MeuCampo] ASC)
After the line : db.SaveChanges();
nothing happens and does not change the value.
I am not managing to change the value 9 to 10. What I am doing wrong ?
Makes a mistake:
The property 'MeuCampo' is part of the object's key information and cannot be modified.
– Matheus Miranda
Keys cannot be modified by definition. Just deleting the record and inserting another.
– Leonel Sanches da Silva