Customize feed for WCF Data Services using Entity Framework (Code First)
Can anybody tell me how to customize the OData feed for Ado.Net Data Services using Entity Framework (Code First/Only)?
There is no EDMX file (as it is Code Only).
I have tried adding the attribute:
[EntityPropertyMapping( "Id" , SyndicationItemProperty.Title , SyndicationTextContentKind.Plaintext , true )]
To my POCO entity classes but nothing shows up in the feed title tag?
UPDATE:
If I was using an EDMX file I could customize the feed by applying attributes like this:
<EntityType Name="Customer">
<Property Name="myAddress" Type="MyModelNamespace.Address"
me:EpmSourcePath="Street"
开发者_如何学Pythonm2:FC_Atom="true"
m2:FC_TargetPath="EpmSyndicationTitle"
m2:FC_ContentKind="EpmPlaintext"
m2:FC_KeepContent="true"/>
</EntityType>
But I am not using an EDMX file - I am using Code Only. My question is about achieving the same thing when using Code Only (no XML file).
Thanks!
Have you set the access rules for your entity sets?
as a catch all for testing you should have something like:
public class NorthwindService : DataService<NorthwindEntities>
{
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
}
}
精彩评论