I'm having problems with entity framework
The problem is pretty simple, I have a database in sql server 2008. When I import the tables for creating the edmx file in a visual studio 2010 project (using ADO.NET Entity Data Model), not all of relationships are replicated in the model, just some of them. I've tried deleting an recreating the model, updating and even in a completely new project the same problem becomes....
for example:
This entity is called "simte_plandeestudio"
The creating script for this table is:
CREATE TABLE [dbo].[simte_PlanDeEstudio](
[Id] [uniqueidentifier] NOT NULL,
[Estudiante] [uniqueidentifier] NULL,
[Curso] [uniqueidentifier] NULL,
[Duracion] [int] NOT NULL,
[Meta] [int] NOT NULL,
[Estado] [int] NOT NULL,
[FechaFinalizacion] [datetime] NULL,
[Tutor] [uniqueidentifier] NULL,
[FechaInicio] [datetime] NOT NULL,
[MotivoRetiro] [varchar](50) NULL,
[FechaIngresoTaller] [datetime] NOT NULL,
[FechaMatricula] [datetime] NOT NULL,
[TiempoTranscurrido] [int] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
**ALTER TABLE [dbo].[simte_PlanDeEstudio] WITH CHECK ADD CONSTRAINT [FK_simte_PlanDeEstudio_simte_Curso] FOREIGN KEY([Curso])
REFERENCES [dbo].[simte_Curso] ([Id])
GO
ALTER TABLE [dbo].[simte_PlanDeEstudio] CHECK CONSTRAINT [FK_simte_PlanDeEstudio_simte_Curso]
GO**
**ALTER TABLE [dbo].[simte_PlanDeEstudio] WITH CHECK ADD CONSTRAINT [FK_simte_PlanDeEstudio_simte_Estudiante] FOREIGN KEY([Estudiante])
REFERENCES [dbo].[simte_Estudiante] ([Id])
GO
ALTER TABLE [dbo].[simte_PlanDeEstudio] CHECK CONSTRAINT [FK_simte_PlanDeEstudio_simte_Estudiante]
GO**
ALTER TABLE [dbo].[simte_PlanDeEstudio] WITH CHECK ADD CONSTRAINT [FK_simte_PlanDeEstudio_simte_Usuario] FOREIGN KEY([Tutor])
REFERENCES [dbo].[simte_Usuario] ([Id])
GO
ALTER TABLE [dbo].[simte_PlanDeEstudio] CHECK CONSTRAINT [FK_simte_PlanDeEstudio_simte_Usuario]
GO
ALTER TABLE [dbo].[simte_PlanDeEstudio] ADD CONSTRAINT [DF_simte_PlanDeEstudio_Id] DEFAULT (newid()) FOR [Id]
GO
The first two constraints ("simte_Curso" and "simte_Estudiante") are seen in the sql management studio diagram, but not passed to the model.
The last one ("simte_Usuario") is in the database diagram and is passed to the model.
The "simte_curso" entity has not foreign keys, and "simte_usuario" has only one foreign key related to another table
I hope it could be more clarifying
the creation scripts for "simte_curso" and for "simte_Usuario" are :
**CREATE TABLE [dbo].[simte_Curso](
[Id] [uniqueidentifier] NOT NULL,
[Nombre] [varchar](50) NOT NULL,
[Orden] [int] NOT NULL,
[UltimoCurso] [bit] NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]**
**CREATE TABLE [dbo].[simte_Usuario](
[Id] [uniqueidentifier] NOT NULL,
[UsuarioOrchard] [int] NOT NULL,
[TipoDeUsuario] [varchar](10) NOT NULL,
[Nombres] [varchar](50) NOT NULL,
[Apellidos] [varchar](50) NOT NULL,
[Documento] [varchar](50) NULL,
[TelefonoMovil] [varchar](50) NULL,
[FechaDeNacimento] [datetime] NULL,
[CorreoElectronico] [varchar](50) NULL,
[sexo] [bit] NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[simte_Usuario] WITH CHECK ADD CONSTRAINT [FK_simte_Usuario_Orch_Orchard_Users_UserPartRecord] FOREIGN KEY([UsuarioOrchard])
REFERENCES [dbo].[Orch_Orchard_Users_UserPartRecord] ([Id])
GO
ALTER TABLE [dbo].[simte_Usuario] CHECK CONSTRAINT [FK_simte_Usuario_Orch_Orchard_Users_UserPartRecord]
GO**