I'm planning to create a web application using MVC 4 Single page application and I will use database first approach.
Where should I put the edmx file? Under the Model folder? What if I want to have a service layer/repository layer.
BTW, the default template of SPA create two classes for each model, for example 'TodoList.cs' and 'TodoListDto.cs'. Why and is there any better design to avoid two classes?
BTW, the default template of SPA create two classes for each model, for example 'TodoList.cs' and 'TodoListDto.cs'. Why and is there any better design to avoid two classes?
DTO, by definition, is Data Transfer Object (it's actually also one of enterprise application patterns). The point of DTO is to have simple object to just carry data between application layers and not to have complex dependencies like domain objects may
have. In current case it comes to serializing - only binary serialization is able to handle cyclomatic references in .NET. XML and JSON serialization are not able to handle situations where objects reference to each other. Although you have simple objects
in sample application it is possible you add later more complex objects that cannot be JSON-serialized.
Often DTO-s live in serives layer where implementing of application use cases actually happens. Depending on architecture of service layer, DTO-s may also live in presentation layer, of course. This is the decision of architect to make.
I hope you understand the background of these classes better now.
Don't forget to mark solution providing post as "Answered".
ydbn
Member
6 Points
45 Posts
Entity framework, repository layer and Asp.net MVC 4
Jan 28, 2013 11:12 PM|LINK
I'm planning to create a web application using MVC 4 Single page application and I will use database first approach.
Where should I put the edmx file? Under the Model folder? What if I want to have a service layer/repository layer.
BTW, the default template of SPA create two classes for each model, for example 'TodoList.cs' and 'TodoListDto.cs'. Why and is there any better design to avoid two classes?
ignatandrei
All-Star
135231 Points
21695 Posts
Moderator
MVP
Re: Entity framework, repository layer and Asp.net MVC 4
Jan 29, 2013 06:36 AM|LINK
I will put edmx in a separate dll.
Please see http://msprogrammer.serviciipeweb.ro/2010/03/29/asp-net-mvc-orm-and-viewmodels/
ydbn
Member
6 Points
45 Posts
Re: Entity framework, repository layer and Asp.net MVC 4
Jan 30, 2013 04:15 AM|LINK
I'm using SQL localDb with login/authentication tables. Can I move these tables to localDB of the class library project too?
DigiMortal
Contributor
5658 Points
939 Posts
MVP
Re: Entity framework, repository layer and Asp.net MVC 4
Jan 30, 2013 05:33 AM|LINK
DTO, by definition, is Data Transfer Object (it's actually also one of enterprise application patterns). The point of DTO is to have simple object to just carry data between application layers and not to have complex dependencies like domain objects may have. In current case it comes to serializing - only binary serialization is able to handle cyclomatic references in .NET. XML and JSON serialization are not able to handle situations where objects reference to each other. Although you have simple objects in sample application it is possible you add later more complex objects that cannot be JSON-serialized.
Often DTO-s live in serives layer where implementing of application use cases actually happens. Depending on architecture of service layer, DTO-s may also live in presentation layer, of course. This is the decision of architect to make.
I hope you understand the background of these classes better now.
Also visit my ASP.NET blog or follow me @ Twitter:twitter.com/gpeipman