how to connect to a sql server database in asp.net mvc
Hai guys,
how to connect to a sql server database in asp.net mvc ... I know it can be done easily in asp.net web application us开发者_StackOverflow社区ing web.config and in the aspx pageSystem.Configuration.ConfigurationManager.ConnectionStrings["database"].ConnectionString;
You can connect to a database in MVC the same way you would in an asp.net web app. There's no difference, save that in a web app you have a code behind, and in MVC you have a controller and presumably a model. Other than that, creating a connection to your database is completely up to you.
I would suggest using an ORM (Such as Linq to SQL)... in addition to SQL server so you can take full advantage of the "M" model part of MVC...
精彩评论