Solved

advice on website architecture .net 4

Posted on 2012-03-14
2
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
navneethegde earned 250 total points
ID: 37723622
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
ID: 37724189
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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