Avatar of Michael Sterling
Michael SterlingFlag for United States of America asked on

.edmx and foriegn keys / relationships errors

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


Avatar of undefined
Last Comment
Michael Sterling

8/22/2022 - Mon
Michael Sterling

sorry in the above, the line that reads:


at the end of the XML description of my utinouts table, should only read:


must have dragged and dropped the link accidentally. it is not part of the description...
Michael Sterling

also within the XML descriptions of the two tables, i see the following: not the error before each XML description of the two tables in question:

        <!--Errors Found During Generation:
      warning 6035: The relationship 'fk_utinout_utathleteinfo' has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded.
        <EntityType Name="utathleteinfo">
            <PropertyRef Name="AthleteInfoAUid" />
          <Property Name="Active" Type="bit" />
          <Property Name="AthleteFirstName" Type="varchar" MaxLength="25" />
          <Property Name="AthleteInfoAUid" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="AthleteLastName" Type="varchar" MaxLength="25" />
          <Property Name="AthleteName" Type="varchar" MaxLength="50" />
          <Property Name="AthleteSSN" Type="varchar" MaxLength="11" />
          <Property Name="AthleteUid" Type="varchar" Nullable="false" MaxLength="8" />
          <Property Name="BankedMinutes" Type="int" />
          <Property Name="BankedTime" Type="varchar" MaxLength="50" />
          <Property Name="GPA" Type="varchar" MaxLength="4" />
          <Property Name="Major" Type="varchar" MaxLength="45" />
          <Property Name="Notes" Type="varchar" MaxLength="255" />
          <Property Name="RequiredHours" Type="int" />
          <Property Name="SemesterTotal" Type="int" />
          <Property Name="SignedIn" Type="bit" />
          <Property Name="SportUid" Type="int" />
          <Property Name="TotalMinutes" Type="int" />
          <Property Name="UsedBankedMins" Type="int" />
          <Property Name="WarningCount" Type="int" />
          <Property Name="WeekTotal" Type="varchar" MaxLength="50" />
        <EntityType Name="utgparequiredhoursmap">
            <PropertyRef Name="GPARHMUid" />
          <Property Name="GPA" Type="double" Nullable="false" />
          <Property Name="GPARHMUid" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="RecommendedPowerHours" Type="int" Nullable="false" />
        <!--Errors Found During Generation:
      warning 6035: The relationship 'fk_utathleteinfo_utinout' has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded.
        <EntityType Name="utinout">
            <PropertyRef Name="InOutAUid" />
          <Property Name="AtAProgram" Type="bit" />
          <Property Name="AthleteUid" Type="varchar" Nullable="false" MaxLength="8" />
          <Property Name="InOutAUid" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="InTime" Type="datetime" Nullable="false" />
          <Property Name="OutTime" Type="datetime" />
          <Property Name="SignInOutNotes" Type="varchar" MaxLength="255" />
          <Property Name="StudentName" Type="varchar" MaxLength="50" />
          <Property Name="TotalMinutes" Type="int" />
          <Property Name="TotalTime" Type="varchar" MaxLength="8" />
Kumaraswamy R

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Michael Sterling

thank you for your help
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes