//entity is empty is the database context validates the physical validation varentity = db. Userinfo.where (U = u.mobile = =mobile). FirstOrDefault (); if(Entity! =NULL) {Mobilelogmodel.addmobilelog (Dvid, Dvtype,"User Registration","Mobile is registered","Userinfo-register"); returnJson (result, jsonrequestbehavior.allowget); } Public Static voidAddmobilelog (stringTitlestringmsg) { using(Dao.giftdbentities db =Newdao.giftdbentities ()) { //let db not validate entityDb. configuration.validateonsaveenabled =false; Dao.mobilelog Log=NewDao.mobilelog (); Log. Mobilelogid=Utility.getguid (); Log. Createtime=DateTime.Now; Log. Title=title; Log. Content=msg; Db. Mobilelog.add (log); Db. SaveChanges (); //let DB validate the entity againDb. configuration.validateonsaveenabled =true; } }
ASP. NET Mvc4 fails validation on one entity or multiple entities when EF is new