Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

entity framework  - The value can not be null.

Posted on 2010-08-18
5
Medium Priority
?
814 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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