Ravi Gadag
Ravi Gadag

Reputation: 15861

How to Connect Sql Database in Asp.net MVC3 for beginners level

i used to develop application in ASP.Net, in that case we can use ADO.net and connection strings, and also code behind files.
but here MVC is nice way to separate the bussines logic. so i'm learning to implement the architecture.

I'm making a sample application, in which were Questions and Answers are stored in database (Sql Server 2008), its same as like Stackoverflow.com, as i am beginner in Asp.net MVC 3, i'm not able to connect the Database within Application.

I came accross the MOdel concept by using ORM ( Linq to Sql ), but as i am beginer i'm not able to get the all ideas. i want to do CRUD operation with the database, Using MVC 3,

and also i come to know there is helper methods for CRUD operation, but i really don know how to implement with database. Help me how to Insert, Update, Edit, Delete Data in Database

Upvotes: 3

Views: 12983

Answers (2)

prokaryote
prokaryote

Reputation: 21

You can follow this tutorial.

If you're new to Dependency Injection (DI), I think that's the only road block for your learning. Though, a separate tutorial is mentioned in the given link.

You can play around also with some source code to have a better grasp of MVC 3.

Upvotes: 2

Ofer Zelig
Ofer Zelig

Reputation: 17508

The answer to your question is very broad. There are a lot of techniques to architect your application in terms of how to get/set data and how to correctly separate concerns. But for the beginning, please understand the basic fact that MVC is a platform for web development and has nothing to do with data access. MVC provides you the infrastructure to build web application in a very efficient and straightforward way (relative to the old WebForms platform). But when it gets to data, the 'M' of MVC means 'Model', which folds behind it an infinite range of options to get to the data. It's best to actually do that in separate assemblies (and even not use the Model folder created automatically in a project by the New MVC Application visual studio template).

There is a great book to start learning MVC from, which covers some important architectural aspects like how to access the database and how to "componentize" your architecture and keep it maintainable.

This is the book: http://www.apress.com/9781430234043 Please note that under 'Source code/Downloads' tab you can download a ZIP with complete demo projects you can learn from.

Good luck!

Upvotes: 4

Related Questions