Entity Framework sin includes de tablas relacionadas
https://msdn.microsoft.com/es-es/library/bb896272%28v=vs.100%29.aspx?f=255&MSPPError=-2147217396 http://www.entityframeworktutorial.net/EntityFramework4.3/lazy-loading-with-dbcontext.aspx
- Para deshabilitar la carga diferida, establezca la propiedad LazyLoadingEnabled en false en la instancia de ObjectContextOptions devuelta por la propiedad System.Data.Objects.ObjectContext.ContextOptions
*Solución*:
- public AbcRestaurantsEntities(): base("name=AbcRestaurantsEntities")
{
this.Configuration.LazyLoadingEnabled = false;
}
- Eliminar todos los decoradores 'virtual'
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None;
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); //json en minusculas
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter); //error get desde navegador
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
//GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;