开发者

Sybase ASE Entity Framework - Error while updateing record to database -"incorrect syntax near '('.\n"

I am trying to simple update and existing record. And I am getting the error - incorrect syntax nea开发者_Go百科r '('.\n

Entities db = new Entities();

   try
    {

           var existingObj = new OBJETE
            {
                OB_ID_MR = 348,
                OB_ID_JE = 1156,
                OB_IS_NT = false,
                OB_ID_MS = 88,
                OB_POSITIONABS = "12,12,12,12",
                OB_ORDRE = 1,
                OB_UPDATEDATE = DateTime.Now
            };
            db.OBJETEs.Attach(existingObj);
            db.ObjectStateManager.ChangeObjectState(existingObj, System.Data.EntityState.Modified); 
            db.SaveChanges();

If I try to update "not null" columns then I can update the records in this table. But when I try to update nullable values then I am getting this error consistently. Please advice.


Found it! My Table did not have a Primary Key. Entity Framework add some addition tag to disable update of such tables.

So either you add a primary key to the table or if that is not an option like in my case the work around is to open the edmx file in Text mode, and remove the entry for the tag - "DefiningQuery" and all its contents for the Table in question. Additionally we need to change => store:Schema="dbo" to Schema="dbo" for that Table. This should fix the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜