One or more validation errors were detected during model generation:

Posts   
 
   
 
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 25-May-2015 12:45:14   

Hi there,

My database is structured as follows:

Idea (1) ... (m) IdeaVsTag (m) ... (1) Tag

IdeaVsTag is structured as follows:

Idea_ID (FK) Tag_ID (FK)

The primary key is a composite of Idea_ID and Tag_ID.

When I generate the EF6 code, I get the following in the code in the ModelBuilder:


        /// <summary>Defines the mapping information for the entity 'IdeaVsTag'</summary>
        /// <param name="config">The configuration to modify.</param>
        protected virtual void MapIdeaVsTag(EntityTypeConfiguration<IdeaVsTag> config)
        {
            config.ToTable("IdeaVsTag");
            config.HasKey(t => new { t.IdeaId, t.TagId });
            config.Property(t => t.IdeaId).HasColumnName("Idea_ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            config.Property(t => t.TagId).HasColumnName("Tag_ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            config.HasRequired(t => t.Idea).WithMany(t => t.IdeaVsTags).Map(m => m.MapKey("Idea_ID")).WillCascadeOnDelete(true);
            config.HasRequired(t => t.Tag).WithMany(t => t.IdeaVsTags).Map(m => m.MapKey("Tag_ID")).WillCascadeOnDelete(true);
        }

When I try to use the generated code, I get the following error message:

One or more validation errors were detected during model generation:

Idea_ID: Name: Each property name in a type must be unique. Property name 'Idea_ID' is already defined. Tag_ID: Name: Each property name in a type must be unique. Property name 'Tag_ID' is already defined.

Have I modeled something wrong?

Cheers

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 25-May-2015 21:19:39   

IdeaVsTag is structured as follows:

Idea_ID (FK) Tag_ID (FK)

Is there a unique constraint defined on either of the above FKs?

Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 26-May-2015 00:49:37   

I've scrapped the project and started again. It seems to be working now, which is strange. If it happens again, I'll update the thread.

Cheers

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-May-2015 04:48:54   

lad4bear wrote:

I've scrapped the project and started again. It seems to be working now, which is strange. If it happens again, I'll update the thread.

Good you figured it out. Please let us know if you need further help.

David Elizondo | LLBLGen Support Team