I'm trying to generate CSDL xml suitable for an OData $metadata endpoint, however I am not using Entity Framework or anything similar. Currently I just want to generate the $metadata XML document for a small set of ~3 classes...
My code looks like the following...
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.AddEntity(typeof(Member));
var model = modelBuilder.GetEdmModel();
IEnumerable<EdmError> errors;
CsdlWriter.TryWriteCsdl(model,
XmlWriter.Create(HttpContext.Current.Server.MapPath(...),
out errors);
...however, the output XML is always empty. I've tried modelBuilder.Entity<>
, modelBuilder.AddEntity(type)
, modelBuilder.EntitySet<>
etc to no avail.
The Member
class is simply public getters and setters - do I need attributes? What is the best way to generate $metadata XML if you're not hosting it or using EntityFramework?
Apologies if this is a basic question, but I can't find any documentation for this that doesn't assume you're using EF or hosting from an OData endpoint, and I'm doing neither of these things.