SQLStart ASP.Net Configuration

I'm trying to pick up ASP.Net - and after the mvc tutorial: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4 (Note: I am completely new to .Net, like C #, so ASP.Net)

At the beginning, the tutorial suggests using SQL Server Compact 4.0. But instead, I installed SQL Server Express (since I will use it after, and not just for the tutorial).

SELECT @@VERSION AS [Version]

Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86) Apr 2 2010 15:53:02 Copyright (c) Microsoft Corporation Express Edition with Advanced Services on Windows NT 6.1 <X64> (Build 7600: ) (WOW64)

Now I am having problems when I got to the point to set up a db connection for the tutorial. Lesson step to add this to Web.config:

<connectionStrings>
    <add name="MusicStoreEntities"
         connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
         providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>  

But this will not work - and it is very important because I am using a different SQL Server. Suggestion on how to make this work?

"System.Data.SqlClient", , :

  <connectionStrings>
    <add
       name="MusicStoreEntities"
       connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|MvcMusicStore.sdf"
       providerName="System.Data.SqlClient" />
  </connectionStrings>

- : ProviderManifestToken

ASP.Net - SQL Server Express 2008 !


, , , db:

  

, , - , - db "SampeData.cs" Global.asax.cs Application_Start:

System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData());

, 2 :

  • , Application_Start, , ( )

  • : , . , IncludeMetadataConvention DbModelBuilder.

, db - , / -

+2
3

, SqlExpress. , . connectionstrings http://www.connectionstrings.com

  <connectionStrings>
    <add
       name="MusicStoreEntities"
       connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;Database=MusicStoreEntities"
       providerName="System.Data.SqlClient" />
  </connectionStrings>

, .sdf, SqlCE. | DataDirectory | App_Data .

+2

, :

<add name="<CONNECTION NAME>" 
     connectionString="Data Source=<SERVER NAME>;Initial Catalog=<DATABASE>;Persist Security Info=True;User ID=<USER ID>;Password=<PASSWORD>;" 
     providerName="System.Data.SqlClient" />

<... > .

+1

I never remember the connection string, I used this site to find out what they needed.

0
source

All Articles