Faust
Faust

Reputation: 15394

Generate model classes from Entity Framework for MVC2

I am following Steven Sanderson's "Pro ASP.Net MVC2 Framewok", which uses Linq2SQL. He uses abstract factory approach to support unit testing and mocking, and writes model classes in a separate project to facilitate this.

I am using Linq to Entity Framework instead of Linq2SQL, and I have built an entity model in EF from an existing database. (I am new to all of this).

I don't quite understand if I'm getting this right, but I beleive I should still generate model classes defined outside of EF (a layer between EF and presentation?), even though I could just pass Linq2EF query results entities directly in as MVC's models (security? separation of concerns?).

So I'd like EF to stub the model classes for me instead of hand-coding them all from scratch. Is there an easy way to do this, or am I mis-interpreting what I need to do?

Upvotes: 0

Views: 1963

Answers (1)

SimonGates
SimonGates

Reputation: 6111

Take a look at this blog great resource on this subject.

If you are going to use ViewModels I highly recomend using AutoMapper from souceforge

Upvotes: 1

Related Questions