Servicio WCF OData y problema de EF 6: no se pueden exponer entidades con el Servicio Odata

Estoy usando WCF Data Service (Odata) con .NET framework 4.5.1 y EF 6.1. He usado el primer enfoque de código para crear el modelo EF. Cuando hago referencia a este modelo EF (AddProjectModel.cs) al servicio WCF OData (WcfDataService1.svc), arroja el siguiente error:

Error:

El servidor encontró un error al procesar la solicitud. El mensaje de excepción es 'En el tipo de contexto de datos' AddProjectModel ', hay una propiedad IQueryable superior' Activos 'cuyo tipo de elemento no es un tipo de entidad. Asegúrese de que la propiedad IQueryable sea del tipo de entidad o especifique el atributo IgnoreProperties en el tipo de contexto de datos para ignorar esta propiedad '. Vea los registros del servidor para más detalles. El seguimiento de la pila de excepción es:

en System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadata (ProviderMetadataCacheItem metadataCacheItem) en System.Data.Services.Providers.BaseServiceProvider.LoadMetadata (Boolean skipServiceOperations) en System.Data.Services.DataSviceices.DataServices.DataServices.DataServices.DataServices.DataServices.DataServices.DataServices1.CreateInternalProvider(Object dataSourceInstance) at System.Data.Services.DataService1.CreateMetadataAndQueryProviders (IDataServiceMetadataProvider & metadataProviderInstance, IDataServiceQueryProvider & queryProviderInstance, Object & dataSourceInstance, Boolean & isInternallyCreatedProvider) en System.Data.Services.DataService.1.CreateProvider() at System.Data.Services.DataService1.HandleRequest () en System.Data.Services.DataService`1.ProcessRequestForMessage (Stream messageBody) en SyncInvokeProcessRequestForMessage (Object, Object [], Object []) en System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke (instancia de objeto, Object [ ] entradas, Objeto [] y salidas) en System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin (MessageRpc & rpc) en System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5 (MessageRpc & rpc.Res.Marco. .f. ImmutableDispatchRuntime.ProcessMessage2 (MessageRpc & rpc) en System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11 ( MessageRpc & rpc) en System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1 (MessageRpc & rpc) en System.ServiceModel.Dispatcher.MessageRpc.Process (Boolean isOperationContextSet)

Aquí está mi servicio de datos WCF: WcfDataService1.svc

namespace AddProjectService
{
 public class WcfDataService1 : DataService<AddProjectModel>
 {
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    {
        // TODO: set rules to indicate which entity sets and service operations are visible,
         updatable, etc.
        // Examples:
        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    }
 }
}

Mi primer modelo de código: AddProjectModel.cs

 public partial class AddProjectModel : DbContext
 {
  public AddProjectModel()
    : base("name=AddProjectModel")
  {
  }

  public virtual DbSet<Asset> Assets { get; set; }
  public virtual DbSet<Project> Projects { get; set; }

  protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
    modelBuilder.Configurations.Add(new AssetMap());
    modelBuilder.Configurations.Add(new ProjectMap());   
  }         
 }  

 public class AssetMap : EntityTypeConfiguration<Asset>
 {
  public AssetMap()
  {
  this.Property(a => a.AssetId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);      
  this.HasMany(a => a.Projects).WithRequired(p => p.Asset).HasForeignKey(p => p.AssetId);

  //table  & column mappings
  this.ToTable("TBLASSET");
  this.Property(a => a.AssetId).HasColumnName("ASSETID");
  this.Property(a => a.AssetLevelId).HasColumnName("ASSETLEVELID");
  this.Property(a => a.AssetNumber).HasColumnName("ASSETNUMBER");
  this.Property(a => a.Name).HasColumnName("NAME");
  this.Property(a => a.AssetTypeId).HasColumnName("ASSETTYPEID");      
 }
}  

public class ProjectMap : EntityTypeConfiguration<Project>
{
  public ProjectMap()
  {
   this.Property(p => p.ProjectId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
   this.HasMany(p => p.SchedulePhases).WithRequired(sp => sp.Project).HasForeignKey(sp => 
   sp.ProjectId); 

  //table & column mappings
  this.ToTable("TBLPROJECT");
  this.Property(p => p.ProjectId).HasColumnName("PROJECTID");
  this.Property(p => p.AssetId).HasColumnName("ASSETID");
  this.Property(p => p.CapitalCategoryId).HasColumnName("CAPITALCATEGORYID");
  this.Property(p => p.Comments).HasColumnName("COMMENTS");
  this.Property(p => p.DesignationId).HasColumnName("DESIGNATIONID");
  this.Property(p => p.DispositionId).HasColumnName("DISPOSITIONID");
  this.Property(p => p.FMSNumber).HasColumnName("FMSNUMBER");
  this.Property(p => p.FundingSourceId).HasColumnName("FUNDINGSOURCEID");
  this.Property(p => p.ImplementerId).HasColumnName("IMPLEMENTERID");
  this.Property(p => p.IsApproved).HasColumnName("ISAPPROVED");
  this.Property(p => p.IsDeferred).HasColumnName("ISDEFERRED");
  this.Property(p => p.IsLongTermLease).HasColumnName("ISLONGTERMLEASE");
  this.Property(p => p.IsRollover).HasColumnName("ISROLLOVER");
  this.Property(p => p.IsSidewalkBridge).HasColumnName("ISSIDEWALKBRIDGE");
  this.Property(p => p.JobDescription).HasColumnName("JOBDESCRIPTION");
  this.Property(p => p.JobType).HasColumnName("JOBTYPE");
  this.Property(p => p.OrganizationId).HasColumnName("ORGANIZATIONID");
  this.Property(p => p.ProgramCategoryId).HasColumnName("PROGRAMCATEGORYID");
  this.Property(p => p.DsfId).HasColumnName("DSFID");
  this.Property(p => p.StatusId).HasColumnName("STATUSID");

  this.Map<DomainObjectModel.ObjectModel.Project.ProjectCIP>(m => m.Requires("PROJECTTYPEID").HasValue(15))
      .Map<DomainObjectModel.ObjectModel.Project.ProjectCapacity>(m => m.Requires("PROJECTTYPEID").HasValue(2));
 }
}

Clase de activos:

public class Asset
{
 public Asset()
 {
   Projects = new HashSet<Project>();      
 }

 [Key]
 public decimal AssetId { get; set; }

 [StringLength(20)]
 public string AssetNumber { get; set; }

 [StringLength(100)]
 public string Name { get; set; }

 public decimal? AssetLevelId { get; set; }

 public decimal? AssetTypeId { get; set; }

 public virtual ICollection<Project> Projects { get; set; }    
}

Clase de proyecto:

public class Project
{
 public Project()
 {      
 } 

 [Key]
 public decimal ProjectId { get; set; }

 public decimal AssetId { get; set; }

 public decimal CapitalCategoryId { get; set; }

 //public decimal ProjectTypeId { get; set; }

 public decimal ProgramCategoryId { get; set; }   

 [StringLength(1024)]
 public string Comments { get; set; }

 public decimal ImplementerId { get; set; }

 public decimal StatusId { get; set; }

 public decimal DsfId { get; set; }

 [StringLength(20)]
 public string FMSNumber { get; set; }

 [StringLength(1024)]
 public string JobDescription { get; set; }

 [StringLength(2)]
 public string JobType { get; set; }

 public decimal OrganizationId { get; set; }

 [Required][StringLength(1)]
 public string IsRollover { get; set; }

 [Required][StringLength(1)]
 public string IsDeferred { get; set; }

 [Required][StringLength(1)]
 public string IsApproved { get; set; }

 [StringLength(1)]
 public string IsSidewalkBridge { get; set; }

 public decimal FundingSourceId { get; set; }

 public decimal? DesignationId { get; set; }

 public decimal? DispositionId { get; set; }

 [Required][StringLength(1)]
 public string IsLongTermLease { get; set; }

 public virtual Asset Asset { get; set; }   
}

No sé cómo resolver este problema. ¿Podría decirme qué me estoy perdiendo aquí?

Estoy usando la base de datos Oracle y hemos comprado una licencia de devart para dotConnect para Oracle recientemente.

Gracias,

Hola,

He resuelto este error configurando el atributo [DataServiceKey] con la clave primaria en cada clase de POCO. Por favor refiérase esto:http://blog.marcgravell.com/2008/12/astoria-and-linq-to-sql-getting-started.html.

Ahora puedo exponer entidades a través del servicio Odata, pero cuando trato de acceder a la colección de entidades escribiendo URL (ej. ... / WcfDataService1.svc / Assets) arroja el siguiente error:

Error:

 <?xml version="1.0" encoding="utf-8" ?> 
 <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
   <m:code /> 
   <m:message xml:lang="en-US">An error occurred while processing this request.</m:message> 
   <m:innererror>
     <m:message>Operation could destabilize the runtime.</m:message> 
     <m:type>System.Security.VerificationException</m:type> 
     <m:stacktrace>at queryable_reader(Object ) at   System.Data.Services.Providers.ReflectionServiceProvider.GetQueryRootForResourceSet(ResourceSet container) at System.Data.Services.Providers.ReflectionDataServiceProvider.GetQueryRootForResourceSet(ResourceSet resourceSet) at System.Data.Services.Providers.DataServiceProviderWrapper.GetQueryRootForResourceSet(ResourceSetWrapper resourceSet) at System.Data.Services.RequestUriProcessor.ComposeExpressionForEntitySet(SegmentInfo segment, IDataService service, Boolean isLastSegment, Boolean checkRights) at System.Data.Services.RequestUriProcessor.ComposeExpressionForSegments(IList`1 segments, IDataService service, Boolean isCrossReferencingUri) at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service, Boolean internalQuery) at System.Data.Services.DataService`1.ProcessIncomingRequestUri() at System.Data.Services.DataService`1.HandleRequest()</m:stacktrace> 
  </m:innererror>
 </m:error>

¿Cómo resuelvo esto?

Gracias,

Respuestas a la pregunta(1)

Su respuesta a la pregunta