asp.net mvc - EF code-first how to use POCO objects in client layers -


i'm new asp.net mvc , ef, excuse me if question not clear or easy.

i have read tutorials ef code-first approach , i'm trying tutorial getting started ef using mvc.

using code-first approach i'm using poco classes define db model, db logic, db validation, ui validation , ui logic. can use these classes(or objects) in presentation layer or use them json objects when dealing web-services(or in javascript code).

my question: isn't mixing logic together? mean shouldn't use special view-model classes presentation , these classes should have ui logic , validation ?!

is practice send poco object view(or client in general) ?

finally need guidance on how organize project layers or folders? see many ways , i'm confused choose or format should base own on?!!

you should not use data entities in higher layers of application. transform/compose/copy data dal view model or business classes using library automapper. keeps layers of application independent , hides database schema end users.

keep in mind mvc concerned presentation, real work should happen in other layers of app. try keep layers independent , use little bit of glue code bundle them app. may write data access , business logic layers when working on mvc project, re-use in command line utility. there lot of books talk writing quality code. found clean code, code complete 2, , design patterns extremely helpful.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -