Kaps Hasija
Kaps Hasija

Reputation: 2177

How to reset the identity column in C#?

I need to reset my identity field parametrically in MVC.net. I am using Linq and Entity Framework.

Reason: I am inserting thousands of records in my table by importing. I am importing records again after some period of time, so my id field value increasing so much

For ex. In 100000000 so my field data type is Big int but it is not sufficient for my this value. So I need to reset my identity field.

Upvotes: 2

Views: 7512

Answers (1)

Kaps Hasija
Kaps Hasija

Reputation: 2177

Hi I have searched and found answer for my related question.

that is the query in c# with mvc3 and entity framework

 db.ExecuteStoreCommand("DBCC CHECKIDENT('BibContents',RESEED,1);");
 db.SaveChanges();

Upvotes: 8

Related Questions