Entity framework 4 &引用;ObjectNotFoundException“;捕获或抛出的类型必须从system.exception派生

Entity framework 4 &引用;ObjectNotFoundException“;捕获或抛出的类型必须从system.exception派生,entity-framework-4,Entity Framework 4,在.NET4上使用实体框架 这是我的密码: using (frfcourEntities frf = new frfcourEntities()) { EntityKey routehdrId = new EntityKey("frfcourEntities.Routehdrs", "Refno", "xxx"); try{ var routehdr = frf.GetObjectBy

在.NET4上使用实体框架 这是我的密码:

        using (frfcourEntities frf = new frfcourEntities())
        {
            EntityKey routehdrId = new EntityKey("frfcourEntities.Routehdrs", "Refno", "xxx");
            try{
                var routehdr = frf.GetObjectByKey(routehdrId);
                frf.DeleteObject(routehdr);
                frf.SaveChanges();
            }
            catch(System.Data.ObjectNotFoundException)
            {}
        }
该行:

catch(System.Data.ObjectNotFoundException)
不会编译。它报告

The type caught or thrown must be derived from System.Exeception. 

但是ObjectNotFoundException是EF GetObjectByKey方法抛出的。

向System.Data添加程序集引用。如果没有它,“使用System.Data”可以工作,但不能解决DataException