ID == existingCompany. Parent = a; }) Put mappings creation to application start code (or before first usage of mapping). MapFrom(src => src. Aug 11, 2020 · Likewise, I want to reverse the procedure - taking a collection of DTOs with a common parent into one of model objects. Values; items. Tags, opt => opt. ForMember(d=> d. ChildBundle) before Where statement. Map<Child>(parent); Is there a method available to do this without mapping the members one by one using . CreateMap<SourceObject, TargetObject>(); Oct 25, 2021 · When mapping a dto parent with a child collection to an entity framework model parent with child collection, changes and additions to the child collection work fine; when the model child contains an entity that isn't in the the dto collection, the context. CreateDate, config => config. This is a real issue when the parent has a large nvarchar field, and there are lots of elements in the child collection. But I don't need Parent's Child. But this approach doesn't work for child properties. . Dec 1, 2014 · I am trying to bind a child collections from my viewmodels to the domain model in the controller and I do not know how. Looks good so far except I am having problem with updating records. One of these methods is to use another type map, where the source member type and destination member type are also configured in the mapping configuration. since they have same name, and there is already a mapping from Person to PersonDto. e. Childs, opt => opt. For example, I have the following DTO classes. Include<Child, ChildDto>(); CreateMap<Child, ChildDto>(); Nested Mappings. Parent = parentObject added a child in parentObject automatically. Here is an working example for your code: public StudentsMappingProfile() CreateMap<StudentValueObject, StudentDetailsViewModel>() The parent object has a property which is a collection of child objects: public class Parent { public List<Child> Children { get; set; } } public class Child { public string A { get; set; } public string B { get; set; } public string C { get; set; } } I have two instances of Parent: Feb 18, 2010 · The first child should have a Position of 1, a Contents value of "Things", and a Group value of "GroupOne". I am comfortable with getting one-to-one custom mapping set up in AutoMapper using ValueResolvers, but I am not sure how best to handle this. try. Extensions. g. This allows us to not only flatten our source types and. id == parentId Nov 24, 2014 · 23. static void Main(string[] args) {. ChildBundle, opt => opt. 1'. Nov 21, 2012 · Products = new List<ProductDto>(); And I'd like to map a list of domain objects to list of Dto objects such that the "Products" property of ProductListDto object AUTOMATICALLY is mapped with a list of ProductModel objects: /* dto = (ProductListDto) Mapper. I made a sample program you can copy paste that shows the problem. Inheriting base class configuration is opt-in, and you can either explicitly specify the mapping to inherit from the base type configuration with Include or in the derived type configuration with Feb 27, 2016 · Automapper has very basic support for two way mapping out of the box via the ReverseMap () method which will allow you to reverse a map in one line rather than two like below: In the above scenario ReverseMap () makes things slightly cleaner but as the original A to B mapping is very simple we are really only saving a few characters. Mapping Child Collections using AutoMapper. Ask Question Asked 9 years, AutoMapper: Mapping child collections. Map(changedCompany, existingCompany); This works for all ID properties at Company level (mappedCompany. CreateMap<Child, ChildDTO>(); AutoMapper mapping configuration works on a single (source, target) level. Aug 8, 2017 · Mapper. Name Dec 7, 2012 · AutoMapper Newbie Question. Items. Also this resolver will not cover case when Destination Collection is collection of derived items from parent Sep 7, 2018 · I use projection to map the Entity classes to DTOs using Entity Framework Core. EDIT: Oh, just noticed the page is being passed into your service. So, I have a promotion object, that has a collection of localisedPromotion objects. CreateMap<Source, Dest>() . When mapping AutoMapper will skip open generic type maps during configuration validation, since you can still create closed types that don’t convert, such as Source<Foo> -> Destination<Bar> where there is no conversion from Foo to Bar. com/roelvandepaarWith thanks & pra dest => dest. var derivedObj = new T(); Mar 30, 2015 · 1. Dec 15, 2015 · The DstParent has a collection of DstChild objects, that use constructor injection to keep a reference to their parent. The "out of the box" way to update any entity, whether it be a parent or a child in some collection is: Fetch entities from the database. In certain cases where the child entity contains a lot of fields and the inclusion to the parent entity is optional, I think it would be clearer to have a child entity in the target type as well. CreateMap<PropertySurvey, PropertyToSurveyOutput>() . OData. RemoveAll (y => y == null)); I can't compile this unless I have a semicolon at the end of line 1 and remove the comma before the 'AsQueryable ()'. InnerChild, opt => opt. Include (b => b. ANestedProperty) ); // This is in my controller: Flattened myFlattened = Mapper. Nov 16, 2020 · In particular, what I'm trying to achieve is that all the properties of the mapped class are correctly set. CreateMap<DomainClass, Parent>() . To() to map objects and sort a child collection: Projection transforms a source to a destination beyond flattening the object model. Bonus points if I can use IValueResolver to use type1 or type1extended if extended is filled. Ignore()); Mar 25, 2019 · I am calling the AutoMapper in the following code and when it calls the mapper the 'viewModel' has all the 'Gear' in the 'GearLevel' but when the 'registerCommand' returns it is missing multiple 'Gear' in the 'GearLevel' with the same name. Occasionally, you might need to perform custom logic before or after a map occurs. Net Core 3 project. Apr 4, 2021 · 1. ID, it ignores changedCompany. then use ConstructUsing method for set child object to null when dto child object is null and also get full model by id when dto child object comes only with ID property. CreateMap<Employee, Employee>(). 1 since it works well for regular projection code. CreateMap Oct 6, 2021 · I want to map Parent class with ParentMap class. Options when calling map as documentation. Condition(d => d. , opt => opt. But I don't see other solution (except manual synchronization which defeats the usage of AM) because Map simply replaces the target collection with brand new, which is causing EF to try disassociating the exiting child entities from their parent, hence the exception. 2. Otherwise it should use type2. Tree. ForType<Record, List<Model>>(). Introduction. CreateMap<Person, PersonDto>(); Mapper. CreateMap<ParentChildDTO, Parent>() . CreateMap<Item, ItemModel>(); /* Create a mapping from Source to Destination, but map the nested property from. ChildBundleId)) . The second child should have a Position of 2, a Contents of "Things", and a Group of "GroupTwo". PropertyName, opt => opt. Childs. Oct 15, 2015 · Mapper. /* mapping configuration */. Basic = 0. 0 I have another query that gets a parent and includes all child records without a filter so if possible I would like to implement something outside of the Dto mapping configuration. To convert to string is easy, however to convert the string back to type I wrote a ValueConverter. ArgumentException: 'Expression 'dest => dest. You just need to define the mappings of each element type, as the documentation for Nested Mappings suggests. However, projection adds ToList into child collection properties and this slows down the query a lot. I am using automapper to map from model to dto. Dec 28, 2019 · 1. MapFrom(ps => ps. TopicTag' must resolve to top-level member and not any child object's properties. ForMember(dest => dest. Projection fails but I can do manual projection which fits my goals Source/destination types public class Parent { public int Id { get; set; } public Child [] Children { get; set; } public string May 19, 2022 · Because I sort of use Mapster inside of Mapster config ) It must be the way to point the source path like this: config. Sep 4, 2017 · System. Locations. GetThread(threadId, page); thread. MaxDepth (2) Classes: (There is more fields than shown below) public partial class Bundle. Is it possible to configure Automapper so that the query is done in two parts? E. CreateMap<ParentData, Parent>(); Mapper. Post, page); var viewModel = Mapper. CreateMap<Parent, ParentDto>() . Thats how I define the mapping rule: . 1. Tests. CreateMap<ParentDTO, ParentObject>() . Jun 13, 2016 · @Sauron I have just tested to confim that CreateMap<Tomato, TomatoViewModel>() is all you need configuration wise to correctly map the objects and recurse the child collections as expected. {. As the mapping engine executes the mapping, it can use one of a variety of methods to resolve a destination member value. With the standard mapping of: Mapper. Nov 12, 2012 · AutoMapper collections of strings to object properties in a collection of objects. Configuration. Parent = parentObject is not enough anymore When using AutoMapper to map child collections in a ViewModel, you can utilize AutoMapper's collection mapping capabilities. I was also able to reproduce the issue with the AutoMapper. ChildIds ? I've tried doing something like this: Jul 21, 2011 · public string Name {get; set; } } Than in a model I have a IList of this class. Such as: Parent GetParent(bool includeChildren); So far the only feasible solution I found was to either create a wrapping class to add a boolean property, like: 2. Mar 31, 2020 · We can use an “Include" method to map parent and child relationships. I want to set a specific localisedPromotion and set it as my defaultLocalisedPromotion. Select(x => x. Here's an example of how you can achieve this: Let's say you have a domain model Parent with a collection of Child entities, and you want to map it to a ParentViewModel with a collection of ChildViewModel objects. Here's an example of how to use Project(). public long Id { get; set; } public string Type { get; set; } public string Text { get; set; } Jul 13, 2017 · Both the identifying-relationship and non-identifying relationship child collections are on the same parent object. When you want to project source values into a destination that does not exactly match the source structure, you must specify custom member Feb 5, 2022 · Code Review: Automapper - Mapping a nested collection to a listHelpful? Please support me on Patreon: https://www. Company Entity: public Company() Employees = new List<CompanyEmployee>(); public string Address { get; set; } public virtual ICollection<CompanyEmployee> Employees Aug 7, 2013 · Basically I need to go from a single object, with a nested list, to a list of objects with values from the nested list and the parent object. the source itself */. BeforeMap((src Jun 1, 2015 · There seems to be a limitation in AutoMapper with regards to this approach. ChildId to ParentViewModel. 1', Children: Id: 3; Name: 'Question 1. Data); But all such attempts lead to: Always empty destination collection in Mapster. This allows me to use the Automapper. I'm using Automapper for Below Source to Destination Mapping. Inheriting base class configuration is opt-in, and you can either explicitly specify the mapping to inherit from the base type configuration with Include or in the derived type configuration with Sep 12, 2016 · Mapper. Can this be done in AutoMapper? I realize that I can easily map the Events list and get a list of EventDTO objects and then manually set the SystemId and UserId, it would just be very convenient to let Before and After Map Action. ForPath to pass and assign value from the parent to the child AutoMapper use parent class mapping in child classes. Steps to reproduce Given a class with both a collection property defined with { get; private set; } and a collection property using the auto-property with initializer pattern: Feb 24, 2018 · Im trying to map a parent entity that includes a default child entity. NegelectedChildren collection. You can also create an open generic type converter: var configuration = new MapperConfiguration(cfg => cfg. I think you want something like this: Mapper. OData v2. net core,you have to see this article : Integrating For LEFT JOIN you will get a null item in the location list. Map<ObjectEditView>(entityFromDb); And some times it fails with exception. ID as expected whilst the other properties change). (I tried using automapper and did not get very far). But I want the elements of the User collection to May 31, 2013 · I have an MVC 4 sample application using code first (POCO), EF, ViewModels and AutoMapper. var registerCommand = _mapper. TheNestedClass. ConstructUsing(item => new Parent. SaveChanges throws a System. Children, Dec 7, 2010 · The mapping works fine to create the List collection with correct data but I need to have a ForEach to assign the parent instance reference. In my actual program I am mapping collections so it would require to loop over entire collection to set all the nested object to null and The trick I always use is to work backwards, starting with a mapping between the types inside the collections and then going up a level. So this allows you to reuse the configuration in the existing map for the child types InnerSource and OtherInnerSource when mapping the parent types Source and Destination. So define my mapping profiles to ignore it on both the parent and child views: CreateMap<TestClassView, TestClass>() . Taxes, opt => opt. I think the only way to populate a child object in a collection with a reference to parent instance of the member collection without using . For the source object I do the following: For the source object I do the following: CreateMap<ParentA, ParentB>() . It works with EF Core and EnableQuery out of the box but the expansion of the last parent seems to be ignored by AutoMapper (using AutoMapper. CreateMap<Parent, ParentDTO>(); Mapper. ANestedProperty. Hot Network Questions Has ever a country by its own volition refused to Aug 13, 2018 · I'm still not understanding how this can be applied to Entity Framework because if you map a parent/child relationship you'll get the entire list in which case it would update everything. How can AutoMapper map these? Simplified source and destination DTOs share the same names: Customer Orders Invoices CustomerInfo This options instructs AutoMapper to use the existing property on the target object and map any child properties or collection items into that object rather than creating a new proxy object. The order of the parameters in the IncludeMembers call is relevant. Here is my minimum viable product/demo. Automapper is a popular object-object mapper in . Using a ValueConverter in combination with ForMember is working var thread = _forumService. I have a source and destination DTO that have the same fields and child collections. Translate equality between dto and EF object to an expression of just the EF using the dto's values as constants. While it is a nested child, I am using ForPath instead ForMember. ForMember When i pass this into Automapper, to map it to the following DTO. I have set lazy loading for child collections. Map<List<ProductModel>, List<ProductDto>>((List<ProductModel>)model); this code line Queryable Extensions. May 14, 2013 · However, here is one of the easiest ways to do this and it's reusable. Initialize(cfg =>. ForMember(x => x. Type Map configuration. Collection extensions via the EqualityComparison () extension method. Automapper 5. public MyEnum Type { get; set; } public string Text { get; set; } I have a TemplateModel defined, like so, which i want to convert to. Conventions; Nested Mappings. Add(child) had the same result in real time (while debugging == before SaveChanges), so I decided to use child. Unable to cast object of type 'ObjectShortEditView' to type 'ObjectEditView '. Children wen you invoke Map(). cfg. PropertyName)); Jun 28, 2015 · This will return the parent DTO object with all its children as DTO objects. InnerChild object(Its ok to set it to null). Taxes != null)); Its not working well. } The reason I'm using a method to add children to the collection is to maintain control of business logic that needs to be processed when a child is added. CreateMap<ChildData, Child>(); //Populates both the Parent & List of Child Dec 2, 2014 · I truly expected the child mappings occur automatically, but they don't, I've already created too much "proper" code to solve a really simple problem which in any other simpler/older non-MVC environment, I'd be done with a long time ago :) How can I proceed and tell AutoMapper to transform the children without writing another "children member Mar 26, 2018 · Given what you are going to use this for based on your comments - the below configuration should do the job (parent properties are resolved by default AutoMapper conventions so no need to explicitly map): AutoMapper. My config posted above is default behaviour as already pointed out. ' Mar 14, 2018 · Mapping Child Collections using AutoMapper. 2 and probably should work for EF Core 3. This makes it possible to have a null value to notate missing child entity. Use a custom resolver on the child type or the AfterMap option instead. You can create global before/after map actions: var configuration = new MapperConfiguration(cfg => { cfg. If the header object has a prop set to 1 then it should map field type1 in the child to type in the destination. If one object needs to go up 2 levels, it's time to use ForMember to get to a nested property. CreateMap<BaseChild, DerivedChild>(); May 25, 2013 · Usually child entities has reference to parent entities. In this case I don't want CreateDate to be settable by the view, as it is a generated field. public class ParentChildMapper. The child was also added to the db. British child with Italian mother travelling to Italy AutoMapper provides several ways to map objects between different types, including the Project(). Id, opt May 17, 2018 · The CommunityIndex property uniquely identifies a CommunityModel instance. In this article, we will discuss how to use Automapper for nested mappings in C#, specifically focusing on how to share parent-child information between classes and their respective DTOs. It works in a similar way to mapping inheritance, but it uses composition, not inheritance. So the same MapperConfiguration instance and even the same Mapper instance are in use for both sets of child updates, where I'm seeing the differing behavior. The models involved look like this: Parent Model #1: public class ParentModel. NegelectedChildren is empty regardless of the number of elements in the source Parent. To declare an attribute map, decorate your destination type with the AutoMapAttribute: This is equivalent to a CreateMap<Order, OrderDto>() configuration. Oct 10, 2015 · Is it possible to update child collection in EF out of the box is: yes. Nov 29, 2021 · As we have different Objects, we need to tell automapper which objects and fields are mapped and from where, using the method ForMember and MapFrom. I also have a Producer class that handles the conversion between object model and DTO by calling the relevant factory method. Where baseObj would be the parent object and T would be the child class. But it will stop mapping entire Child object. I have a hierarchy of parent > children models and DTO using C# and AutoMapper 7 in a . I already have all the information on what I am working on, so to save trees I figured it might be easy to put a link, instead of repeating the same code. See that the main Object the automapper does automatically without mapping the fields, but, when it comes to the Object Value Attributes I had to map one by one so it would understand where the AutoMapper supports polymorphic arrays and collections, such that derived source/destination types are used if found. Oct 12, 2021 · as a result, I need to build a collection of parent-child like this: Id: 2; Name: 'Question 1. I see no way to pass the parent to the child source configuration. AfterMap() is with a custom TypeConverter<TSource, TDestination>. -> Children { node1, node2 } Once the view model is mapped to the entity, the first child node, of the root node, is the root node and, as a result, I'm getting an infinite loop when I traverse the entity object structure. Posts = new PaginatedList(thread. If I wanted to create a new function to get just Parent with id '1', I would at the moment have to duplicate the select statement to add a where clause: public IHttpActionResult GetParent(int parentId) { var parents = from p in _context. public class ChildDTO. AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for Sep 25, 2019 · With Automapper 7 i use this code to map child property: Mapper. If your ORM exposes IQueryable s, you can use AutoMapper Sep 16, 2015 · var view = Mapper. public class WebApplicationMenuModel. Oct 10, 2018 · parentObject. If, however, we supply a common resolver across multiple types, we configure AutoMapper to redirect the source value supplied to the resolver, and also use a different resolver interface so Jan 12, 2013 · The purpose here is to conditionally map a collection of child objects based on a web service operation parameter. Children. I've already tried with ForPath() as below. When using an ORM such as NHibernate or Entity Framework with AutoMapper’s standard mapper. CreateMap<LocalisedPromotion, LocalisedPromotionViewModel>() . You have several approaches here: Create the condition to execute the map on children youself: 2. Also, you are only allowed to provide the additional value to Context. public int Id { get; set; } public string Title { get; set; } Mar 1, 2021 · Automapper 7. Name, o=> o. May 31, 2023 · However, doing so creates queries where every line in the parent is duplicated for each line in the child collection. ForPath(o => o. public string Label { get; set; } public string Route { get; set; } public float Sequence { get; set; } public IEnumerable<WebApplicationMenuModel> Children { get; set; } } The grandchildren from my original object are set to null. What is happening is that we're getting all the properties of the parent class and updating those same properties on the child class. I have tried: . 4. Now I want to map the name's to a collection of strings. Mar 2, 2018 · Entity framework populares the nested entities in a loop so I end up with the parent nested inside the nested child entity after mapping. Domain objects Jan 20, 2016 · I am trying to map object's of the same type which have a collection of child objects and am finding that Ignore() applied to properties on the child object seem to be umm ignored! Here's a unit test which demonstrates the problem. 1. Map<RegisterNewHeroCommand>(viewModel); Mapping inheritance serves two functions: Inheriting mapping configuration from a base class or interface configuration. MapFrom(src => src)); /* Then also create a Jan 17, 2019 · Automapper parent-child self referencing loop. There is a Child collection with in Source Object, and I want to use the First Item of that item for mapping. ConstructUsing(. CreateMap<DomainClass, Child>(); Mapper. CreateMap<SrcChild, DstChild>() . using AutoMapper; using AutoMapper. Feb 22, 2024 · 1. 1). Below is the Source and Destination Classes: public string Name { get; set; } public List<InnerSource> InnerSources { get; set; } public string InnerName { get; set; } Feb 22, 2024 · Automapper: Nested Mappings Sharing Parent-Child Information in C#. Using AutoMapper, I tried the following: class Program. I don't want Automapper to initialize the Users collection, because it gets initialized in the class constructor. So, here's all I have to do in my application: Mapper. If they are not ignored during mapping, AutoMapper will try do mapping: ParentDTO -> SourceCollection -> SourceDTO -> SourceEntity -> ParentDTO which will cause circular mapping. Mapper. Jan 7, 2011 · I'm afraid automapper is not meant to be used for mapping to a populated object, it will erase the Parent. 0. EntityFramework does that as well through extension method from of DbSet. ResolveUsing<TagNameResolver>()) And here is my ValueResolver: protected override string ResolveCore(Tag source) {. ForMember (dest => dest. May 26, 2017 · ParentViewModel. Ignore()) ; CreateMap<ChildClassView, ChildClass>() Apr 24, 2019 · 0. This is the mapping configuration I'm using: var config = new MapperConfiguration(cfg => {. CreateMap<SourceModel, DestinationModel>() . Aug 10, 2016 · Here is my Scoring object which is a child property of Template. NET. Now : child. Child)) . After mapping, I need Parent's Child object. These should be a rarity, as it’s more obvious to do this work outside of AutoMapper. From what I've read, a Factory Pattern seems to be what I'm looking for. Map<Parent, ParentViewModel>(vm); Is it possible to get AutoMapper to translate the list of Child. I don't see why you try to make it complicated, you can use the . I'm using EF to fetch all this data from the DB and build this parent-child relationship on the C# side. Modify their properties or add/remove elements to their collections; Call Jul 21, 2021 · The query below returns plenty of data, but every BundleMetaDataDtos child value is null. What you want to do in this case is to set up the following mappings: Mapper. Entries) entry. BaseContentItem. As per documentation stated starting from version 12, it restricts the accessing of Context. child. -> Root. ForEach (x => x. Map<Thread, ThreadView>(thread); return View(viewModel); } There's probably not an easy way to do just using AutoMapper. public void MapData(ParentData parentData) {. 2. Mapping inheritance serves two functions: Inheriting mapping configuration from a base class or interface configuration. child. Exceptions in AutoMapper: Expression 'dest => dest' must resolve to top Jan 19, 2018 · I need to ensure that the Parent property is set for both collections before mapping occurs. patreon. Property. Map(dest => dest, record => record. CreateMap<Parent, ParentMap>() . IgnoreIDs(); var mappedCompany = Mapper. Mapper. InvalidOperationException which seems to indicate that the AutoMapper uses a fluent configuration API to define an object-object mapping strategy. 1 inheritance mapping. And last - with Automapper you can create mapping and define how to do custom map for some properties: Mapper. You have to tell Automapper how to map ComplexEntityDb -> ComplexEntityVM and how to map EntityCollectionItemDb -> EntityCollectionItemVM, and then all the mappings of collections of those items will automatically be supported. Collection. Map<Root, Flattened>(myRoot); I have looked at a number of examples, and so far this seems to be the way to flatten a nested hierarchy. DestinationNestedViewModel, opt => opt. I am having problems mapping the parent model to the lowest child DTO. Without extra configuration, AutoMapper requires a flattened destination to match the source type’s naming structure. Nov 6, 2017 · I'm trying to determine if Automapper is a viable option for constructing parent/child object graphs from basic DTO collections, and I'm having trouble tracking down an example of the sort of approach I'm hoping for. 0-preview. CreateMap<ParentDTO, Parent>(); Mapper. public class ParentSource { public int Value1 { get ; set ; } } public class ChildSource : ParentSource { public int Value2 { get ; set ; } } public class ParentDestination { public int Value1 { get ; set ; } } public class Aug 24, 2017 · Essentially I would like to do an Automapper configuration that will allow me to map a Parent into the Child. This limits the reusability of resolvers, since the resolver is coupled to the source type. ForMember(obj => obj. CreateMap<PersonDto, Person>(); Note : Because AutoMapper will automatically map the List<Person> to List<PersonDto> . for Construct Child object. I have created a controller where parent and corresponding child entities are on the same view (entity with nested collection of child entities). Map functions, you may notice that the ORM will query all the fields of all the objects within a graph when AutoMapper is attempting to map the results to a destination type. If you need to know how to inject it to ASP. The issue is that the Child property of the mapped class is not set and remains null. Mean while i wrote this i got idea that it could be ignore all extension but why it even try to cast to short view when i ask map me to full view By default, AutoMapper passes the source object to the resolver. Automapper. Parent = parentObject for the readability. Remove them by var items = lookup. How can I do that ? var parent = GetParent(); var child = Mapper. In order to search for maps to configure, use the AddMaps method: AddMaps looks for fluent map configuration ( Profile classes) and attribute-based mappings. ForMember(pts => pts. Map child object to base object using AutoMapper. MapFrom (src => src. The only thing is: you don't do it out of the box. ForMember(d => d. AutoMapper uses a convention-based matching algorithm to match up source to destination values. AutoMapper use parent class mapping in child classes. BeforeMap((a, b) => { foreach (var entry in a. I am getting the following error: The Jul 16, 2021 · I'm trying to expand a child collection and from that child collection, expand a parent. This functionality worked for EF Core 2. In my config I have: config. If you are talking about no changes ignoring the map, what AutoMapper will do is map to existing item, but since there's no change, EntityFramework won't send Jun 3, 2011 · Using the following view model structure. Inheriting base class configuration is opt-in, and you can either explicitly specify the mapping to inherit from the base type configuration with Include or in the derived type configuration with Jun 17, 2018 · You have to map the list properties, cause they have different names in the given parent types and you have to add a mapping for the types used within both lists. Jan 6, 2020 · One more addition. Runtime polymorphic mapping. To() method. EFCore. Child. Of course you can use full projection (LINQ Select) like in the other answer, but if the object being mapped contains a lot of properties, this will lead to a lot of redundant code even if they conventionally match by name. Parents where p. In my model I want to use a string where in my dto I use an Enum. im zw zf xx ds lm zj pn pu jv