/// <summary> /// Es el modelBuilder, metodo que se ejecuta para ponerte en contacto con la BD. /// Se hizo dinamico al recorrer los el assembly y buscar todos los tipos que hereden de BaseEntity y /// a su vez tengan el DataAnnotation [Table] la clase /// </summary> /// <param name="modelBuilder"></param> protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove(new PluralizingTableNameConvention()); var typesToRegisterCore = Assembly.Load("Domain.Core").GetTypes() .Where(x => x.BaseType != null && x.BaseType.Name.Contains("BaseEntity")); foreach (var type in typesToRegisterCore) { foreach (var attr in Attribute.GetCustomAttributes(type)) { if (typeof(TableAttribute).IsAssignableFrom(attr.GetType())) { var table = (TableAttribute)attr; if (table?.Name != null) // verifica si la table y el table.name es null { RegisterInvoke(modelBuilder, type, table.Name); } } } } ConfigurationContext.ConfiguracionApiFluent(modelBuilder); base.OnModelCreating(modelBuilder); }