Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

.Net Entity Framework Reseed SQL Server Table ID Column

public void ResetId()
    {
         try
        {
            using (DaghanKantarEntities context = new DaghanKantarEntities())
            {
                context.Database.ExecuteSqlCommand("DELETE FROM dbo.tbl_MainWeight");
                context.Database.ExecuteSqlCommand("DBCC CHECKIDENT ('tbl_MainWeight', RESEED, 0)");
                context.SaveChanges();

            }
        }
        catch (Exception exp)
        {
            throw new Exception("Hata: Kayıt Resetlenemedi - " + exp.Message.ToString(), exp);
        }

    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Entity #Framework #Reseed #SQL #Server #Table #ID #Column
ADD COMMENT
Topic
Name
9+3 =