ASP.NET 3.5 – Activation Database Beerhouse

The different location where to find string of connection:

In the application BeeHouse the connection string is used in web.config





remove name="LocalSqlServer"/>


add name="TheBeerHouseEntities" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=TheBeerHouseVB;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>


add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=TheBeerHouseVB;Integrated Security=True;" providerName="System.Data.SqlClient"/>



Attach DB to SqlServer
We must attach the DB to sql server in the usual way
to place the aspnetdb.mdf file in the directory:
C: \ Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA (sqlserver 2008)

then with the object explorer window from  sql server management studio – right click – attach db

If you decide to change the models. edmx
Two elements are sigificant
the modification of the default namespace – you must use the the property menu – attribute namespace
the connection with the db: right click – update model from database



Entity Framework allows storing metadata files as resources in the assembly; in the connection string you can tell the Entity Framework to find them there.  The way to do this is to add the CSDL, MSL and SSDL files to your project and set the "Build Action" property on each one to "Embedded Resource".  Then when you specify your connection string, rather than explicitly listing the metadata files, you can just add "metadata=res://*/;" which tells the EF to look for appropriate resources in your apps statically linked assemblies any that it finds. For more information
Connection string – web.config
  <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
"Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."
If you did and tried to find how to resolve this you probably Googled (or Binged) for hours without being able to find the solution that really works.
Well lets put an end to that. Two simple things need to be done:
Step 1. Enabling User Instances on your SQL Server installation
First we are gonna make sure we have enabled User Instances for SQL Server installation.
Go to Query Window in SQL Server Management Studio and type this:
exec sp_configure ‘user instances enabled’, 1.
Run this query and then restart the SQL Server.
Step 2. Deleting old files
Now we need to delete any old User Instances.
Go to your C drive and find and completely DELETE this path (and all files inside):
C:\Users\Username\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
(Dont forget to replace the green text in the path with your current username (if you are not sure just go to C:\Documents and Settings\ path to figure it out).
After deleting this dir you can go to Visual Studio, create ASP.NET WebSite and click on your App_Data folder and choose Add New Item and then choose SQL Server Database and it should work!!!
Add DB on SQLServer2008
rename ASPNETDB.mdf toTheBeerHouse35.mdf and aspnetdb_log.ldf to TheBeerHouse_log.ldf
install it on : C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
attach them with sql
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
Cet article a été publié dans DotNet - Asp. Ajoutez ce permalien à vos favoris.

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )


Connexion à %s