I am writing an MVC application, and thinking of to use Entity Framework.
I have read lots of blogs about EF 4, but one thing that bothers me is the seperation.
I think, in EF, the entities (types) and its mapping with data source (i.e. Stored Proc/ table) should be within the same class library project. If that's the case, then my MVC application will have to use direct reference to that data library. Which I feel
is a bad design.
The ideal design what I feel is that MVC will refer to a class that will have only types (entities), and NOT their mapping with the database interaction code. That is why, I need seperation of these into 2 different layers.
My WCF service will reference both of them, but MVC application will reference only the class library having Entities defined.
Not sure if I folow you, but i tell you how i set things ourt if it helps
MVC Website
ViewModels
ClassLibrary (Business objects)
ClassLibrary (EF)
SQL Server
I have business objects for each entity that handles all comunications with the EF layer using linq
The view models handle complex models, but if I want just a single entity in my model, i will go straight to the business object layer
nirman.doshi
Participant
1521 Points
783 Posts
Best practices Entity Framework 4.0 with MVC?
Oct 20, 2011 11:35 AM|LINK
Hi,
I am writing an MVC application, and thinking of to use Entity Framework.
I have read lots of blogs about EF 4, but one thing that bothers me is the seperation.
I think, in EF, the entities (types) and its mapping with data source (i.e. Stored Proc/ table) should be within the same class library project. If that's the case, then my MVC application will have to use direct reference to that data library. Which I feel is a bad design.
The ideal design what I feel is that MVC will refer to a class that will have only types (entities), and NOT their mapping with the database interaction code. That is why, I need seperation of these into 2 different layers.
My WCF service will reference both of them, but MVC application will reference only the class library having Entities defined.
Is this possible anyway?
Thanks
Nirman
Software Developer
Vadodara, India
ThatsIT
Participant
1026 Points
388 Posts
Re: Best practices Entity Framework 4.0 with MVC?
Oct 20, 2011 05:31 PM|LINK
Not sure if I folow you, but i tell you how i set things ourt if it helps
MVC Website
ViewModels
ClassLibrary (Business objects)
ClassLibrary (EF)
SQL Server
I have business objects for each entity that handles all comunications with the EF layer using linq
The view models handle complex models, but if I want just a single entity in my model, i will go straight to the business object layer