none
Getting Metadata TypeMismatchRelationshipConstraint error for WCF Data Services project RRS feed

  • Question

  • I am also getting this error with a database with composite PK's and FK's. Seems to me that the WCF DS team did not do much testing of 5.6 with complex databases. I have he following database CREATE script and the backup file if anyone on the WCF DS team wants to look at it for testing. I cannot get the metadata to generate but I do get all other functions to work with the database. Seems that ValidationRules.NavigationPropertyTypeMismatchRelationshipConstraint is not working correctly with these complex PK and FK's. Anyone from the WCF DS team know a workaround? I have adjusted the order of the columns in my database tables and in the EDM but that does not resolve the issue.

    You have get the files for the database from the links below.

    Database CREATE Script

    • https://onedrive.live.com/redir?resid=2DBF025665E4D94D%2175963

    Database backup file

    • https://onedrive.live.com/redir?resid=2DBF025665E4D94D%2175964

    Chris Woodruff


    Chris "Woody" Woodruff

    Monday, April 28, 2014 2:27 PM

All replies

  • Hello ChrisWoodruff,

    I am trying to help look into this case.

    >>I am also getting this error with a database with composite PK's and FK's.

    Could you please share the detail information with us?

    >> I have he following database CREATE script and the backup file if anyone on the WCF DS team wants to look at it for testing

    When I try to download the script and backup file, I failed to do it, I do not know why, it always gives me a redirect link. And as far as I know, when we get a shared link from onedrive, it usually ends with .zip as:

    https://onedrive.live.com/redir?resid=16AFFEA93D6251E8!124&authkey=!AM_RwW9CIDLARgc&ithint=file%2c.zip

    So please make sure the link is comlete.

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, April 29, 2014 3:50 AM
    Moderator
  • Try this link http://1drv.ms/1m5VEkt

    If that link does work let me know. It is for both files.

    An example of the issue is that I have 2 tables with composite PK's and a FK that is also a composite of 3 columns. Here are the tables

    The foreign key is 

    ALTER TABLE [dbo].[Batting]  WITH CHECK ADD  CONSTRAINT [FK_Batting_Team] FOREIGN KEY([teamID], [yearID], [lgID])
    REFERENCES [dbo].[Team] ([teamID], [yearID], [lgID])

    I am getting the following error when I run a VS13 project using EF 5 and WCF DS 5.6

    <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <m:code/>
    <m:message xml:lang="en-US">
    An IEdmModel instance was found that failed validation. The following errors were reported: TypeMismatchRelationshipConstraint : The types of all properties in the dependent role of a referential constraint must be the same as the corresponding property types in the principal role. The type of property 'yearID' on entity 'BaseballStatsModel.Batting' does not match the type of property 'lgID' on entity 'Team' in the referential constraint 'Fred'. TypeMismatchRelationshipConstraint : The types of all properties in the dependent role of a referential constraint must be the same as the corresponding property types in the principal role. The type of property 'teamID' on entity 'BaseballStatsModel.Batting' does not match the type of property 'yearID' on entity 'Team' in the referential constraint 'Fred'. TypeMismatchRelationshipConstraint : The types of all properties in the dependent role of a referential constraint must be the same as the corresponding property types in the principal role. The type of property 'yearID' on entity 'BaseballStatsModel.BattingPost' does not match the type of property '...
    </m:message>
    </m:error>




    Chris "Woody" Woodruff

    Tuesday, April 29, 2014 11:46 AM
  • Hello ChrisWoodruff,

    Thanks for sharing these information for us.

    The reason seems to be that there is a limit for composite key: they should be the same type. Because if I modified the Batting table and Team table as:

    CREATE TABLE [dbo].[Batting] (
    
        [yearID]    SMALLINT      NOT NULL,
    
        [lgID]      SMALLINT  NOT NULL,
    
        [teamID]    SMALLINT  NOT NULL,
    
    [playerID]  NVARCHAR (10) NOT NULL,
    
    …
    
    CREATE TABLE [dbo].[Team] (
    
        [yearID]     SMALLINT       NOT NULL,
    
        [lgID]       SMALLINT   NOT NULL,
    
        [teamID]     SMALLINT   NOT NULL,
    
    [franchID]   NVARCHAR (3)   NOT NULL,
    
    …

    It could work fine.

    I will try to connect to the team to see whether there is such a limit.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, April 30, 2014 9:47 AM
    Moderator
  • this worked with previous versions of WCF DS!! Look at http://baseball-stats.info/baseballstats.svc/$metadata

    How can it work for WCF DS that targeted OData v2 and not now??

    You really cannot make me believe that I have to conform my database design to fit into a non-OData protocol bug?

    Will talk to the OData team about this since I think it is a bug.

    Chris Woodruff


    Chris "Woody" Woodruff

    Wednesday, April 30, 2014 11:39 AM
  • Hi ChrisWoodruff,

    >>You really cannot make me believe that I have to conform my database design to fit into a non-OData protocol bug?

    I do not know whether it is by designed and I have posted it to the team to confirm it:

    https://connect.microsoft.com/VisualStudio/feedback/details/865299/must-composite-keys-type-be-same-in-wcf-data-services-is-this-by-designe

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, May 2, 2014 5:48 AM
    Moderator
  • Hi,

    I'm facing similar issue. What was the outcome of this thread?

    I can't access the other link here : https://connect.microsoft.com/VisualStudio/feedback/details/865299/must-composite-keys-type-be-same-in-wcf-data-services-is-this-by-designe

    Facing an error: 2107b380-4efc-4311-861e-7e0c5f6eeb7b


    R.S.S.

    Thursday, January 22, 2015 12:39 PM
  • Ever since EF 6 came along I have had problems with DS. After a long gap I upgraded to DS 5.6.4, EF 6.1.3 and EntityFramework beta. I found I could request entities but metadata threw up the validation error describe above. Previously I have had to iteratively downgrade until it worked. This time I chanced upon the DataServiceConfiguration.DisableValidationOnMetadataWrite property. Setting it to True enabled me to generate a service reference on the client. I haven't hit any operational issues as yet.

    Dick Page

    Monday, June 15, 2015 10:49 AM