0

this is my problem. i changed db position, first it was on an external server and i exported it on my local position (./SQLEXPRESS) now i can't make insert record because it says that the record contain NULL id value. But it is correct because it is an auto-increment and i pass "0" or null for tell my db to insert a row (it is db.mytable.add(myrow) and it is the base behavior). why now it tells me to pass a row with setted id?

this is the simply code

db.Company.Add(company);
db.SaveChanges();

and it give error on SaveChanges

i think it is a db owner problem

2
  • From what type of external server (full instance, Azure) using what tool (SSIS, other)? Commented Nov 1, 2012 at 14:50
  • i'm using EF, the serve is sql server 2008 r2. i used the tool inside sql managment studio, export database and i copied it inside my local Commented Nov 1, 2012 at 15:55

1 Answer 1

2

You should check your DB again. Maybe the code is looking at the wrong DB, like dbo.YourDB instead of NinoEmma.YourDB. Because it can't find your DB, EF Code First will create one and the id column doesn't auto-increment anymore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.