How to configure ASP.NET membership after removing SQL Express 2008 and installing SQL 2008 R2 Enterprise - asp.net

As the title says, I used to have SQL Express 2008 on my machine. After creating a new Web application, Visual Studio would automatically create the aspnetdb.mdf database and add a connection string to the Web.config file.
Since installing the full version I've found, to my surprise, that it's not possible to reference a local .mdf database any more. Firstly, is that true?
With that in mind, I used aspnet_regsql.exe to create an aspnetdb.dbo database on my local server. I then used the 'Server Explorer', in VisualStudio, to attach that database to the 'Data Connections'.
The problem is, every time I create a new web application, it sticks a local SQLExpress connection string into the project template.
Is there something else I have to do to rectify this?
Thanks

Related

How to know if Entity was using SQL Server or not?

I have followed through a tutorial using a "Code First" approach with Entity framework. It seems like Visual Studio was smart enough to create the database for me and setup the tables and everything based on my classes. I have a question about the database that was created.
I notice that the database was automatically set up and I could see it in my Server Explorer window in Visual Studio. In my Web.config, under the connection string, I see Data Source=(localdb)\v11.0;.... There is also a .mdf file created in a folder called App_Data.
My question is:
Was Entity framework using MS SQL Server or SQL Express for the database it has created?
If it wasn't using MS SQL Server or SQL Express, what was the database that Entity used?
I don't remember installing SQL Server or SQL Express. Does installing Visual Studio automatically install MS SQL Server or SQL Server Express?
PS: I will appreciate if you can help me to clear up my doubts. Coming from a PHP background, I'm very new to .NET and its ecosystem.
The connection string indicate that you are using SQL Server Local DB.
With Microsoft SQL Server 2012, Microsoft has introduced a feature called LocalDB which is a new edition of SQL Express. LocalDB is created specifically for developers and it is much easier to install (no service) and manage than standard editions. Developers initiate a connection by using a special connection string. It supports AttachDbFileName property, which allows you to specify a database file location.
When connecting, the server is automatically created and started, enabling the application to use the database without complex configuration tasks. This edition uses the same sqlservr.exe as the regular SQL Express and other editions of SQL Server.
http://msdn.microsoft.com/en-US/evalcenter/dn434042.aspx
http://technet.microsoft.com/en-us/library/hh212961.aspx

ASP.NET User/Role Management in VS2010 - skipping over the SQL Express version and going straight to SQL Server 2008 R2

As I'm learning the ins and outs of ASP.NET user management, I've learned that the default in VS is for it to use a SQL Server Express .mdf file for the data it needs to save. This won't help me for when I deploy my site, as I'm running SQL Server 2008 R2 on my IIS 7.5 server. I know that I can run a command line tool to automatically create the db tables necessary for user management, and will do that on my development machine, but how do I tell my existing, in development code in VS to ignore the existing Express .mdf file and look at the newly created db tables?
Simply update your Web.Config to set up the role provider and the database connection string:
http://weblogs.asp.net/scottgu/archive/2006/11/20/common-gotcha-don-t-forget-to-clear-when-adding-providers.aspx
http://www.codersbarn.com/post/2008/02/24/ASPNET-20-Guest-Book-Admin-Part-II.aspx
Also, Scott Mitchell's Membership and Roles tutorial series is the most comprehensive I've seen:
http://weblogs.asp.net/scottgu/archive/2006/05/07/ASP.NET-2.0-Membership-and-Roles-Tutorial-Series.aspx

SQL Server 2008 user instance database creation failure within an asp.net project

I'm trying to create a database within the app_data folder of an asp.net mvc project using the IDE, but i am getting a "Required Components Missing" message indicating "Connections to SQL Server files (*.mdf) requireSQL Express 2005 ....."
I am using
- Windows 7 Enterprise
- VS2008 Team System SP1
- SQL Server 2008 Developer Edition SP1
I have altered the database connection to use the default instance by setting to blank using
Tools -> Options -> Database Tools -> Data Connection : SQL Server Instance Name
I also note from the SQL Server Books Online that the user instance feature will be removed in the future, but for now it suits my effort in developing an application where a number of people are working on the project.
Has anyone managed to create a database in the same manner?
It appears Nerd Dinner has done so
The attached user-instance database in the App_Data will work only with a SQL Server Express edition - 2005 or 2008.
It does not work with a full SQL Server edition, like Web, Workgroup, Standard, Enterprise or Developer. It does not - no way - no trick to make it work - does not - period.
If you want to use that mechanism of attaching a user instance database in your App_Data folder, you must use SQL Server 2005/2008 Express.

SQL server won't open DB created by Visual Studio

I've built an ASP.Net site in Visual Studio, and created the DB inside it (the .mdf file is in the APP_data folder).
Now, when I want to deploy in the customer site, I think about maintaining the DB without open Visual Studio, and by using the SQL Server Express tools (back up etc.).
I've searched how to do this, and learned that I should attach the .mdf file to sql server.
I've tried to do this and failed!
The error is: Unable to open the physical file "< .mdf >". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)
Google didn't helped me to solve the problem.
Now I have 2 options:
1. To give up and deploy the site in the current situation where the DB is an .mdf file and ASP.Net can connect to it by the SQL server express compact (in the proccess).
To extract all the data (I need to think how...) and import it to new DB, this time in SQL Server DB.
Wat would you recommend doing?
Thank you in advance.
If on Windows Vista or higher, try opening SQL Server Management Studio by right clicking and saying "Run as Administrator". As Mitch mentioned maybe it is just a permissions issue. Then try attaching to the database.
Error 5 is usually permissions related. Do you have permissions to access the file in it's location?
If you've created it in Visual Studio, it's most likely an Express database. SQL Server does not support "user mode" database connections which SQL Server Express use. Despite sharing a name, they are two fairly distinctive and different technologies.
To view the contents of an SQL Express database (ie- created in Visual Studio) I just use the Visual Studio server explorer.

Using SQL server 2008 for ASP.net 2.0 Membership provider

I tried to set-up the SQL tables for ASP .net 2.0 membership provider by clicking on ASP.net Configuration under Project.
I have completely uninstalled SQL 2005 Express and installed SQL 2008 Express instead.
It seems like that it can not connect to the database.
Does anybody know how to get this fixed so I can use 2008 instead ?
Try to configuring the database typing "aspnet_regsql" on the VS command prompt.
Then setup the database and finally change de connection string on the web.config file.
ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe)
What is your SQL 2008 installation instance called? What does your connection string for the membership provider look like?
As far as I know, there is (or was) a glitch in the SQL Server 2008 Express installation that even if you chose to install as "default" instance, it would still make it a "named instance" called ".\SQLExpress" instead. Could that be the problem?
Marc
As Marc already has pointed out, it could be the problem with the instance name. This is fixed in service pack 1 for SQL Server 2008 Express. For more information and a workaround, see this Microsoft KB article.
SQL 2005 and 2008 are both configured in a fairly locked down state by default - and this means that SQL won't accept access the database other than through Shared Memory, even with Integrated Security.
You need to enable TCP/IP or Named Pipes for the Client Protocols for the server (as this is how ASP.NET talks to SQL if you've not configured a DSN to use Shared Memory.
I can't remember the exact steps in 2k8, as I've only had to do it once, but in 2k5 you had to open the SQL Server Configuration Manager, select SQL Native Client Configuration, Client Protocols, and enable TCP/IP and Named Pipes - it's a similar process for 2k8 as I recall.
The connectionStringName used in the membership Tag should be changed to the present connection string where you have the membership tables created.
If the connectionStringName is not pointing to a valid connection String name in the connectionStrings tag, the membership tables can not be used by the application.

Resources