Solved

entity framework  - The value can not be null.

Posted on 2010-08-18
5
788 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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