Configure channel for WCF data services using Entity Framework (code first)

Can someone tell me how to configure OData feed for Ado.Net data services using Entity Framework (code first / only)?

There is no EDMX file (as this is just code).

I tried to add an attribute:

[EntityPropertyMapping( "Id" , SyndicationItemProperty.Title , SyndicationTextContentKind.Plaintext , true )] 

In my POCO object classes, but nothing appears in the feed title tag?

UPDATE:

If I used the EDMX file, I could customize the feed using the following attributes:

 <EntityType Name="Customer"> <Property Name="myAddress" Type="MyModelNamespace.Address" me:EpmSourcePath="Street" m2:FC_Atom="true" m2:FC_TargetPath="EpmSyndicationTitle" m2:FC_ContentKind="EpmPlaintext" m2:FC_KeepContent="true"/> </EntityType> 

But I do not use the EDMX file - I use only the code. My question is to achieve the same when using only code (without an XML file).

Thanks!

+4
source share
1 answer

Have you set access rules for your entities?

as a trick for testing, you should have something like:

 public class NorthwindService : DataService<NorthwindEntities> { public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); } } 
0
source

Source: https://habr.com/ru/post/1314544/


All Articles