Here's the table and code
public class Person {
[Key] public int ID {get;set;}
public string Name {get;set;}
}
var owner = new Person() { ID = 1, Name = "Owner" };
db.People.Add(Person);
db.SaveChanges();
The SaveChanges method does not add ID to the sql so I end up with the following sql query
exec sp_executesql N'insert [dbo].[People]([Name])
values (@0)
select [ID]
from [dbo].[People]
where @@ROWCOUNT > 0 and [ID] = scope_identity()',N'@0 varchar(50),@0='Owner'
Rather than the expected insert statement with ID passed in as well.
Is there another attribute I need to make sure the ID is passed as part of the query?
I'm sure it will be asked but it's a non-autoincrement on purpose.