Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Professional ASP.NET MVC 4
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 4
This is the forum to discuss the Wrox book Professional ASP.NET MVC 4 by Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen; ISBN: 978-1-118-34846-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 9th, 2015, 03:35 AM
Authorized User
Points: 200, Level: 3
Points: 200, Level: 3 Points: 200, Level: 3 Points: 200, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , Pakistan.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy AutoMapper exception while using MVC with EF

I am using MVC4 in my project along with EntityFramework (DB first approach). I am using automapper for the mapping of entity to model and vice versa.

Lazy loading and Dynamic proxies are enabled in my edmx.

Now I have defined all the mappings, but still whenever I try to get a list of records from entity and map it to view model, it throws an exception saying:

AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types:
RoutingRule -> RoutingViewModel
Iris.Models.Configuration.RoutingRule -> Iris.Web.Configuration.ViewModels.RoutingViewModel

Destination path:
List`1[0]

Source value:
System.Data.Entity.DynamicProxies.RoutingRule_9573 94C799768B52964A1F1E461B16DD867B73929DE4FE2873D65D C2957D2926


Now notice the dynamic proxy in exception message. After googling the issue, I found the following solution:

http://www.jonegerton.com/dotnet/aut...-a-workaround/

I did implement is but no luck. I googled more & found another solution:

public class LabEntities : DbContext
{
public LabEntities()
{
Configuration.ProxyCreationEnabled = false;
}
}


After doing this, the applications stops lazy loading. All child entities in parent entity becomes null, whenever I fetch data. This created another problem. I tried to solve in the below manner in my DAL:

public IEnumerable<RoutingRule> GetRoutingRuleList()
{
_entities.Configuration.ProxyCreationEnabled = false;
var data = _entities.RoutingRules.OrderByDescending(r => r.Id).ToList();
_entities.Configuration.ProxyCreationEnabled = true;

return data;
}


Now initially it worked fine, but now it gives the old missing mapping error randomly, for the same screen and same data.


Can anyone kindly suggest what is the correct way of using AutoMapper with EntityFramework (Lazy Loading enabled).

Regards,
Shazia.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
EF Repository hpcsc BOOK: Patterns, Principles and Practices of Domain-Driven Design 2 August 26th, 2015 03:26 AM
Scafolding for non-EF? RKevinBurton BOOK: Professional ASP.NET MVC 4 0 March 24th, 2015 09:21 AM
Chpt 4 -- MVC 5 EF Code First Database Generation JackHerr BOOK: Professional ASP.NET MVC 5 0 September 25th, 2014 03:54 PM
Errors while upgrade theBeerHouse mvc project form asp.net mvc 1.0 to 2.0 vanbach1304 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 0 April 20th, 2010 06:43 AM
TheBeerHouse MVC preview ASP.NET MVC Website Programming Problem Design Solution jminatel BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 July 18th, 2009 09:16 AM



All times are GMT -4. The time now is 06:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.