Upgrading from version 3 and all hell is breaking loose! Maybe it's the Cubs? Property is not defined for type

19 views
Skip to first unread message

jwwe...@gmail.com

unread,
Nov 3, 2016, 1:31:39 PM11/3/16
to AutoMapper-users
Hi folks, 

I'm upgrading from a working version 3 to 5 with a ridiculous number of maps defined, so I won't bother to post them here.

I've moved my staticy configs into profiles, and then included them like this.

public static MapperConfiguration Configure()
       
{
           
var mappings = new MapperConfiguration(config =>
           
{
                config
.AddProfile<MapperConfigDomain>();
                config
.AddProfile<MapperConfigModels>();
                config
.AddProfile<MapperConfigDTO>();
                config
.AddProfile<MapperConfigExternalServices>();
           
});


           
return mappings;
       
}

Then moved all of the random CreateMap calls that had been leaked all over into the expected locations.

I'm finally in a compiling state.

But when I try to load the configuration to run a unit test I get

 {"Property xxx is not defined for type yyy"}

Now, the problem is, that it absolutely exists.  At first I thought it was because of a nullable type, but then I completely commented that out as a test and it went on to complain about a bool.  

The properties are named exactly the same and are there across all objects.  Have any of you encountered this?  It does seem like maybe it has something to do with mappings from an interface to a concrete?

Did something change with how this works?

For example..
            CreateMap<ApplicationVehicleModel, ApplicationVehicle>().ReverseMap();


           
CreateMap<IApplicationVehicleModel, ApplicationVehicle>()
                   
.ForMember(dest => dest.Id, opt => opt.Ignore()).ReverseMap();


           
CreateMap<ApplicationVehicleModel, VehicleViewModel>().ReverseMap();


           
CreateMap<ApplicationVehicle, VehicleViewModel>().ReverseMap();


           
CreateMap<IVehicleModel, Vehicle>()
               
.ForMember(dest => dest.Id, opt => opt.Ignore())
               
.ForMember(dest => dest.ClientId, opt => opt.Condition(x => x.ClientId > 0))
           
.ReverseMap()
               
.ForMember(dest => dest.Id, opt => opt.Ignore())
               
.ForMember(dest => dest.ClientId, opt => opt.Condition(x => x.ClientId > 0));


When MapperConfiguration returns I get the following error

{"Property 'Boolean IsExotic' is not defined for type 'Web.Models.VehicleViewModel'"}

public class ApplicationVehicleModel : VehicleViewModel, IApplicationHeaderModel, IApplicationVehicleModel

public class VehicleViewModel {
     
public bool IsExotic { get; set; }
     
...
}

public class ApplicationVehicle {
     public bool IsExotic { get; set; }
     
...
}

public interface IVehicleModel{
     bool IsExotic { get; set; }
     
...
}

public class Vehicle {
     public bool IsExotic { get; set; }

}


Jimmy Bogard

unread,
Nov 3, 2016, 1:38:46 PM11/3/16
to automapper-users
Can you open a GitHub issue for this?

--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jwwe...@gmail.com

unread,
Nov 3, 2016, 1:57:31 PM11/3/16
to AutoMapper-users
In the process of trying to hit backspace somehow it went back and then submitted or something crazy.  Darn you web-browser!

I just don't get it!

Thanks.

jwwe...@gmail.com

unread,
Nov 3, 2016, 1:58:06 PM11/3/16
to AutoMapper-users
Sure thing.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages