Share via


DbConfiguration.SetMetadataAnnotationSerializer Method

Definition

Call this method from the constructor of a class derived from DbConfiguration to set a factory for implementations of IMetadataAnnotationSerializer which allows custom annotations represented by MetadataProperty instances to be serialized to and from the EDMX XML.

protected internal void SetMetadataAnnotationSerializer (string annotationName, Func<System.Data.Entity.Infrastructure.IMetadataAnnotationSerializer> serializerFactory);
member this.SetMetadataAnnotationSerializer : string * Func<System.Data.Entity.Infrastructure.IMetadataAnnotationSerializer> -> unit
Protected Friend Sub SetMetadataAnnotationSerializer (annotationName As String, serializerFactory As Func(Of IMetadataAnnotationSerializer))

Parameters

annotationName
String

The name of custom annotation that will be handled by this serializer.

serializerFactory
Func<IMetadataAnnotationSerializer>

A delegate that will be used to create serializer instances.

Remarks

Note that an Func<TResult> is not needed if the annotation uses a simple string value. This method is provided as a convenient and discoverable way to add configuration to the Entity Framework. Internally it works in the same way as using AddDependencyResolver to add an appropriate resolver for IMetadataAnnotationSerializer. This means that, if desired, the same functionality can be achieved using a custom resolver or a resolver backed by an Inversion-of-Control container.

Applies to