Solved

advice on website architecture .net 4

Posted on 2012-03-14
2
188 Views
Last Modified: 2012-06-27
Hi,

I'm an experienced web developer and am used to having strongly typed classes with a business and datalayer.

I'm wanting to get into interfaces and entity framework 4 so am looking at putting my first project(s) together after my bit of research.

My plan is to have a generic repository within my DAL project which will have its own interface.

In terms of my objects then.... Do I have them in their own library pulling from one.edmx and then the DAL project would have another instance of the same .edmx.

Obviously I would need access to the objects in my fron end project too and am a but unclear about how to go about putting this all together in a correct way.

Swift advice would be appreciated.
0
Comment
Question by:scm0sml
2 Comments
 
LVL 15

Accepted Solution

by:
navneethegde earned 250 total points
Comment Utility
Hi!

1. Have one class library project MyEntity with emdx inside it.
2. And Use Model class Library to Have your POCO Classes.
3. You can Connect Model and myEntity using T4 Template.
4. Use Repository Pattern ovr this


http://blogs.msdn.com/b/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx


Thanks!
0
 
LVL 22

Assisted Solution

by:ambience
ambience earned 250 total points
Comment Utility
Like me you've hit a stumbling block because of trying to mix EDMX and Repository patterns. My thoughts so far:

The Repository pattern looks like a good pattern with Code First strategy, where you have POCO domain objects and don't probably want to annotate them with persistence specific attributes and completely shield away persistence. POCOs are what you'd use in the Repository contracts.

Using ModelFirst or Database first however is somewhat a different story - because the domain objects are not as such in your control. You can put the EDMX in the Contracts assembly but not map the models to any store, or delete the mapping if you started with database first mode. The generated POCOs would have strong dependencies over Entity Framework attributes and objects (will have to live with that or delete manually).

Then in each assembly you can map to a database. The way to do that would be to copy the EDMX to the project, complete the mapping to specific database and then delete the CSDL and keep only the MSL and SSDL as resources.

EF metdata string needs paths to CSDL, MSL and SSDL as well as embedded connection string that the provider would use. This should work

metadata=C:\Entities.csdl|C:\mysql\entities.ssdl|C:\mysql\entities.msl

I'm sure there would be a syntax for loading the ssdl and msl from implementation specific DAL assemblies. I dont actually see a need for different DAL assemblies as such, because a single ObjectContext would work given different mapping files.

I hope that helps ...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now