Link to home
Start Free TrialLog in
Avatar of enrique_aeo
enrique_aeo

asked on

entity framework - The value can not be null.

I have this error
The value can not be null.
Parameter name: key
view attached EFerror

I am using visual studio 2008
actividadEDM.jpg
EFerror.jpg
EF01.jpg
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Does "actividad" have a non-null EntityKey?
Avatar of enrique_aeo
enrique_aeo

ASKER

which verify that?
Put a breakpoint on the line of code where it reads
      db.GetObjectByKey(actividad.EntityKey)

when the breakpoint is hit, use QuickWatch to inspect "actividad".

See if EntityKey was set.
it does not. View file
this is the code the table

CREATE TABLE [certifica].[Actividad](
      [Codigo] [int] IDENTITY(1,1) NOT NULL,
      [CodigoActividad] [bigint] NOT NULL,
      [NombreActividad] [varchar](200) NULL,
      [NombreSede] [varchar](50) NULL,
      [FechaInicio] [varchar](50) NULL,
      [FechaFin] [varchar](50) NULL,
      [DirigidoA] [varchar](200) NULL,
      [NombrePrograma] [varchar](200) NULL,
      [NumeroResolucion] [varchar](100) NULL,
      [HorasLectivas] [varchar](5) NULL,
PRIMARY KEY CLUSTERED
(
      [CodigoActividad] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
enitysetKEYname.jpg
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial