4

For a school project I am building an application that has to be splitted in multiple projects.

The projects that will be made are class libraries, a wcf service and a asp.net MVC4 application.

The class libraries will be a state library, a stateless library and a datalogic library.

Ideally entity framework should be in the datalogic library, the generated models should be placed in the state library and the classes in stateless contain static methods to save those models.

However I can't seem to get the models generated by Entity Framework (v5) to another class library (State). Is there some way to do this? Or do I think wrong, should I use another architecture?

This problem is solved: Entity Framework 5 and Visual Studio 2012 POCO Classes in Different Project

Advice on architecture is still welcome:

I am willing to change this structure, if mine is proven wrong or less efficient as the one adviced.

(Other information I may need to provide is that the WCF service will pass through the methods of the stateless library and the ASP.Net MVC4 application is using those methods to get the models and some controller functionality)

15
  • Are you adding references to the various projects as necessary? Commented Mar 6, 2013 at 19:19
  • 1
    We do a similar thing to this but use CodeFirst EF not db/modelfirst Commented Mar 6, 2013 at 19:19
  • 1
    Are you using the EF DbContext POCO Generator? It's then reasonably straight forward to have the .edmx context and poco models in different assemblies - msdn.microsoft.com/en-US/data/jj206878 Commented Mar 6, 2013 at 19:35
  • 1
    having a database already doesnt prevent you using codefirst. Personally i handstich POCO classes based on the database and use the modelbuilder if i want to represent it differently in the model. However you can also use the CodeFirst Generator to produce a codefirst model from an existing db. Commented Mar 6, 2013 at 19:46
  • 1
    Using database first, or code first, is a matter of preference and isn't really the issue here IMO. Using POCOs should make it easy to separate the models and context as @NeilThompson suggested Commented Mar 6, 2013 at 19:51

1 Answer 1

4

(So you can mark an answer)

Are you using the EF DbContext POCO Generator?

It's then reasonably straight forward to have the .edmx context and poco models in different assemblies - msdn.microsoft.com/en-US/data/jj206878

As you discovered - this post on Entity Framework 5 and Visual Studio 2012 POCO Classes in Different Project explains the procedure well.

Julie Lerman also has downloadable solutions from her books & courses that show POCo T4 templates and lots of other good practices

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.