Hi, I am just getting started with Automapper. I am using version 4.2. I have followed some example that were on the web to get the mapping initialize but seeing the following
AutoMapper.Mapper.CreateMap<TSource,TDestination>() is obsolete. The static API will be removed in version 5.0. Use a MapperConfiguration instance and store statically as needed. Use CreateMapper to create a mapper instance. What do I need to do get this message to disappear?
I am using the automapper on a web api project.
Here is what I have on the
public static class WebApiConfig
{
/// <summary>
///
/// </summary>
/// <param name="config"></param>
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
var cors = new EnableCorsAttribute("*", "*", "GET");
config.EnableCors();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
AutoMapperConfig.RegisterMappings();
}
}
public static void RegisterMappings()
{
AutoMapper.Mapper.CreateMap<Xrm.api_event, Event>();
}