We help IT Professionals succeed at work.
Get Started

.edmx and foriegn keys / relationships errors

Michael Sterling
Last Modified: 2012-08-13
below are the definitions of two tables in my MySQL database. i'm using the database in conjunction with the data entiy modeling tools in ASP .NET (vs 2010). i'm trying to create a proper / valid association, a 1 to many relationship, within the model from the utathleteinfo table to the utinout table.

i create the association on the model side (right click in white space, choose "Add" and select "Association"). then i rebuild. On the model side i get an error that reads:

"Error      1      Error 3004: Problem in mapping fragments starting at line 193:No mapping specified for properties utinout.utathleteinfoAthleteInfoAUid in Set utinouts.
An Entity with Key (PK) will not round-trip when:
Entity is type [STT1Model.utinout]
C:\src\MBSC.DAL\MBSC.DAL\STT.edmx      194      93      MBSC.DAL"

To me this indicates that I can find more information on what this error is saying within the XML of the .edmx file. Though I can see that it's telling me that there there is no mapping specified for the the propertyies utinout.utathleteinfoAthleteInfoAUid in Set utinouts. I can't find where to do this in the model, Because when i click on the property in the model browser, the i get a message in the Mapping Details window that states:

"Mappings are not allowed for an association over exposed foreign keys." (not sure why this is or what this means. So where can I edit the mappings for this?

When i switch to the XML description of the model and go to line 194, (as indicated above) the following description of the utinout table is found:

          <EntitySetMapping Name="utinouts"><EntityTypeMapping TypeName="STT1Model.utinout"><MappingFragment StoreEntitySet="utinout">
            <ScalarProperty Name="AtAProgram" ColumnName="AtAProgram" />
            <ScalarProperty Name="AthleteUid" ColumnName="AthleteUid" />
            <ScalarProperty Name="InOutAUid" ColumnName="InOutAUid" />
            <ScalarProperty Name="InTime" ColumnName="InTime" />
            <ScalarProperty Name="OutTime" ColumnName="OutTime" />
            <ScalarProperty Name="SignInOutNotes" ColumnName="SignInOutNotes" />
            <ScalarProperty Name="StudentName" ColumnName="StudentName" />
            <ScalarProperty Name="TotalMinutes" ColumnName="TotalMinutes" />
            <ScalarProperty Name="TotalTime" ColumnName="TotalTime" />

Also, my error message at this point, before I rebuild, reads:

"Error      1      Error 11009: Property 'utathleteinfoAthleteInfoAUid' is not mapped. Line: STT.edmx      138"

When I go to line 138 within the edmx file, the following line is found:
"<Property Type="Int32" Name="utathleteinfoAthleteInfoAUid" Nullable="false" />"

Remember, this is before I rebuild, with the XML description of the model open. Once I rebuild, I get the same error as I initially described. In short my question is how do I solve this (these) errors?

CREATE TABLE `utathleteinfo` (
  `AthleteInfoAUid` int(11) NOT NULL AUTO_INCREMENT,
  `AthleteUid` varchar(8) NOT NULL,
  `AthleteSSN` varchar(11) DEFAULT NULL,
  PRIMARY KEY (`AthleteInfoAUid`),
  UNIQUE KEY `AthleteUid_UNIQUE` (`AthleteUid`),
  UNIQUE KEY `AthleteInfoAUid_UNIQUE` (`AthleteInfoAUid`),
  UNIQUE KEY `AthleteSSN_UNIQUE` (`AthleteSSN`),
  KEY `fk_utathleteinfo_utinout` (`AthleteUid`),
  CONSTRAINT `fk_utathleteinfo_utinout` FOREIGN KEY (`AthleteUid`) REFERENCES `utinout` (`AthleteUid`) ON DELETE NO ACTION ON UPDATE NO ACTION

  REFERENCES `utinout` (`AthleteUid`)
, ADD INDEX `fk_utathleteinfo_utinout` (`AthleteUid` ASC);


Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE