Reputation: 13
I am entirely new to ASP.NET MVC. I have one ASP.NET 2.0 Framework Web application with below architecture
I am moving the application to an ASP.NET MVC 4 architecture; can anybody suggest the best practices to go with for data access layer, assume the connection string will be in web.config
?
Code-first? Or data-first approach? What is the difference with the above approach and Entity Framework?
Also while adding a controller for a model, amongst the below template which I need to choose?
What is the difference between the above templates?
Upvotes: 1
Views: 1437
Reputation: 13
Okay, I have sample demo project which meets my requirement for data access layer, but i am not sure what approach they have implemented in that sample project. How to find the existing designed data access layer in MVC? Whether its Code/Data first approach and controller templates used?
Upvotes: 0
Reputation: 673
In my experience, I would suggest DB first, but it may depend on your practical implementation.
DB Frist: Generates models from your database. When you change tables etc. you just update your model.
Code First: Creates your database from your model classes. When updates are needed, you may need to write update scripts which will drop and recreate your database.
Regarding your data access, I can recommend checking out Entity Framework if you are unfamiliar.
Regarding controller templates, you would then choose 2. Read/Write with EF. This will create CRUD methods for your model. If you decide against EF, you may go Empty or Empty Read/Write. All the templates just give you Create/Update/Delete methods that you can change if you wish.
Try it out in a test application - once you see the MVC and EF magic you should feel comfortable to make those decisions.
Upvotes: 1