ARTICLE

How to set Connection String in ASP.Net MVC 3 using Entity Framework in VB.NET

Posted by Rohatash Kumar Articles | ASP.NET using VB.NET April 13, 2011
This article explains how to set Connection String in ASP.Net MVC 3 using Entity Framework in VB.NET.
 
Reader Level:

This article explains how to set Connection String in ASP.Net MVC 3 using Entity Framework in VB.NET.

The Sample ASP.NET MVC Application

After the installation of MVC Framework, then you go ahead and create an ASP.NET MVC Web Application by using File -> New -> Project -> Web -> ASP.NET MVC web Application.

add1.gif

Figure1

This will bring up the "New Project" dialog. To create a new ASP.NET MVC application, we'll select the "Web" node on the left-hand side of the dialog and then choose the "ASP.NET MVC Web Application" project template on the right.

add2.gif

Figure2

Now we click Ok Visual Studio will bring up an additional dialog, select Internet Application. Leave Razor as the default view engine.

add4.gif

Figure3

Now add a new item 'ADO.NET Entity Data Model'.

c1.gif

Figure4

Now generate model from database.

c2.gif

Figure5

Now choose data connection.

c3.gif

Figure6

Now click on the next Button.

Now open web configuration file from solution explorer and add the following code.

<connectionStrings>
<add name="masterEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MCNDESKTOP12;Initial Catalog=master;User ID=sa;Password=wintellect;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

To see the connection string in web configuration solution explorer->Web configuration file->right click->open.

c5.gif

Figure7

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor