K.Z
K.Z

Reputation: 5075

architecture ASP.NET MVC 5

I am working on project using ASP.NET MV5 along with Entity Framework. I got few question related to architecture application in best possible way. I Got existing database so i will use code first existing database approach (code or design?) possibly i will use the store procedure as well

now if i use code first existing database design approach, should i have separate models for each business concern or one design (ADO.NET Entity Model). I have just realize some of my model will share among different business functions for example ASP.NET Identity table "Role" is using my dashboard controller where it see, who can use what functions!

can i mix code first existing database--> design & code approach together?

if i use code first existing database design approach, can i go and modify model?

should i have one DbContext for reading database or separate? reason why i am asking if code running under one DbContext brings all data! do i really need that? does it effect performance? security otherwise have multiple DbContext for each business concerns?

I know it is very open questions. i more interesting to see other expert approach in architecture complex application in best possible way using ASP.NET technologies.

Many Thanks

Upvotes: 2

Views: 937

Answers (1)

cygnim
cygnim

Reputation: 2035

For small projects, it's probably ok to just use your entity objects directly. However, if you want to perform complex validation and apply business rules, you're much better off creating separate business objects. Entity objects are, by nature, data objects only.

You can use utilities like AutoMapper to make translating between entity and business objects much easier and eliminate errors and inconsistencies while maintaining clear separate between your business objects and your entity objects.

In the long run, this is a more sustainable architecture.

Upvotes: 1

Related Questions