Solved

entity framework  - The value can not be null.

Posted on 2010-08-18
5
791 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:enrique_aeo
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 33467373
Does "actividad" have a non-null EntityKey?
0
 

Author Comment

by:enrique_aeo
ID: 33469071
which verify that?
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 33469106
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.
0
 

Author Comment

by:enrique_aeo
ID: 33469285
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
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 33469374
Could you use CreateEntityKey before making the call like in

http://msdn.microsoft.com/en-us/library/dd283138.aspx
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RLDC Reporting in Visual studio 11 28
Open a link in vb.net 2 15
abstract class C# 1 31
VS 2015 is giving [No relevant source lines] 2 24
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question