I have a pretty standard situation that's been working however upon creating a new database and running (previously working) code, I get the following error:
Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF
I'm not specifying the ID.
This happens when I do the following:
var newFoo = new Foo{
Name = "test"
}
db.Foos.Add(newFoo);
db.SaveChanges();
public class Foo {
[Key]
public int FooId {get; set;}
public string Name {get; set;}
}
Why would this be happening?