This is a migrated thread and some comments may be shown as answers.

WCF ODATA : The entity type 'Com.DAL.Country' does not have any key properties. Please make sure that one or more key properties are defined for this entity type.

1 Answer 42 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Samuel
Top achievements
Rank 1
Samuel asked on 26 Sep 2013, 02:51 PM
I'm having this error when trying to access my WCF DataService. The country mapping is the following:


        public MappingConfiguration MapEntity()
        {
            MappingConfiguration<Country> mapping = new MappingConfiguration<Country>();
            mapping.MapType().ToTable("Country");
 
            mapping.HasProperty(x => x.Id).WithConverter("OpenAccessRuntime.Data.Bytes2GuidConverter").HasColumnType("raw(16)").IsIdentity();
            mapping.HasProperty(x => x.Version).IsVersion();
 
            return mapping;
        }


The model class:

       
    public partial class Country : BaseEntity
    {
      //some properties here
    }

    public partial class BaseEntity
    { 
        [Required()]
        [Key()]      
        public virtual Guid Id { getset; } 
    }
The error occurs in the OpenAccessMetadataProvider, in method MakeConfigurationReadOnly method

What could be the problem  ? 

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 30 Sep 2013, 11:09 AM
Hello Samuel,

If you are using Horizontal Inheritance for the Country entity type you have to define the Id property in the Country class. See this article on mapping types with Horizontal inheritance.

If it is not the case, please send us details about your whole inheritance chain and the mapping for each participating entity type.

Regards,
Viktor Zhivkov
Telerik
OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
Tags
Web Services
Asked by
Samuel
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or