I am not able to add .mdf file in App_data(vs 2010 visual studio).
If I right click on App_data and try to add existing item and select mydatabase.mdf and click OK I am getting this error:
The file can not be opened because it is used by another process.Please close all applications that might access this file and try again.
But I am just running visual studio.
Not sure if you have found a solution for this, but I just ran into the same problem. I found some relevant info here:
How to add a new database under app_data with SQL Server Enterprise Edition
From this I gather that adding new AND existing databases (ie the .mdf file) via VS2010 is not possible.
I'm assuming (for this answer) that your end goal was the same as mine, i.e. to use the Microsoft Entity Framework to generate a model class from the database.
As I didn't want to install SQL express just to do this my solution was:
-Create any new db via SQL Server 2008 MGMT studio (or a script if you are that way inclined).
-Add a CONNECTION to the database in VS2010
-When adding a new model using the 'Entity Data Model Wizard' select 'Generate from database' and then select your existing connection, and the relevant table(s).
Worked for me!
Related
Recently migrated from vs 2010 -> vs 2013. Observed that there is no Database Schema Viewer in vs 2013 for DB projects. SQL Server Explorer does something similar but when you add new items (say a new table) to a project, noticed two things:
1. the new table file gets created in the root folder and not under the Schema Objects\Schemas\dbo\tables\
2. In vs2010, the table scripts used to have extension XX.table.sql but in vs2013, its always XX.sql
What actions can i take to achieve the above 2 behaviors as in vs 2010
Schema View is no longer part of Visual Studio. You'll have to use a 3rd party tool. If you have SQL Server Management Studio then you can use its database diagrams feature.
Visual Studio no longer manages the folder structure in database projects. When adding a new item, you should add it to the appropriate folder yourself.
To include the schema name in your files go to the database project's properties, select the Project Settings tab, and check Include schema name in file name. This change is not retroactive.
I have this question... probably is similar to Executing scripts from a database project in visual studio
but i didn't understand the solution given.
So i made a Database Server 2008 project inside visual studio.
Just one table. When i press DEPLOY the database is created inside SQLServer2008 and the table is created.
Now what if i would like to give the project to someone who has SQLServer and he needs to recreate the database and the table in his computer?..
Apart form executing the query from Visual Studio is there any way to create an executable that automatically "deploy" from outside Visual Studio?..
Thanks,
There are different types of Database projects in Visual Studio. The old ones, which were not so feature rich. The 'Data Dude' ones that came with Visual Studio 2010 Team Database Edition and the most recent iteration that comes with the SQL Server Data Tools. All of these can be installed on top of the standard Visual Studio Professional and don't require additional licenses.
SQL Server Data Tools is the latest, and also the best integrated and most powerful variant of the bunch. It can also be used to compare existing schema's and generate upgrade scripts or automatically upgrade the schema in an existing database for you.
During build, a package will be created that holds all the schema information for your database. You can then use the command line tools provided by the SQL Server data tools or MSDeploy to deploy your compressed schema file to a new or an existing database.
This deployment mechanism can also upgrade existing schema if needed.
I am a beginner to ASP .net MVC 3. I installed visual web developer 2010 Express. I am learning from online videos. I created a sports project and created all the models as mentioned in the video. But When I switch to Database Explorer I am not able to see the created database where in video It shows the tables. I tried to open a database connection from database explorer but at that it shows that .mdb file is already open. How can I see automatically created database tables in Database explorer?
You need to open the database it won't be added there automatically. If it's already open then maybe you opened it with access or any other 3rd party tool? Just pick a correct provider and open the file. That works for me...
I'm pretty new to Visual Studio so this might be an easy issue :)
I have created a Visual C# SQL CLR Database project where I have created a Trigger. This trigger is supposed to access an IIS on another machine in the network. In order to do this I found that I needed System.DirectoryServices but when I added this VS complained that I needed an assembly. Then I found that I should run the CREATE ASSEMBLY in the MS SQL SERVER. Did that successfully and successfully added my database as a data connection (Server Explorer -> Data Connections). In the Assemblies subfolder I can see the System.DirectoryServices but cannot reference it from the add reference... (when right-clicking references in the solution explorer). When trying to add a reference I have two tabs: Projects (empty) and SQL Server which gives the following error:
The connection to the database failed for the following reason: There
is no available SQL server connection.
No server references can be added at this time, but you may continue
to develop the project.
When I try to add a server connection to either localhost or the machine name of my computer it seems to do nothing (no error but also no server is added in the server explorer).
In Solution Explorer, right click on the Project and select 'Properties'. Select 'Database' tab on the right hand side, then browse to your database or insert a connection string.
I created a database using Server Explorer Visual Studio of name MyDatabase.mdf (and MyDatabase.ldf). Now i want to delete it.I deleted it from Visual Studio using Server Explorer (means removed reference). Then i deleted MyDatabase.mdf and MyDatabase.ldf files from my C directory (C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL).
But when i try creating a new database with same name (MyDatabase), it gives an error and says, database name already exists, try some other name.
There are probably metabase attributes still left in your master table referencing your deleted tables. Instead of just deleting the MDF and LDF files, I would recommend using T-SQL DROP DATABASE statements. If you have MS SQL Management Studio, you could also right-click on your database and choose the "Delete" option.
Are you creating a User Instance of the database? If so, remove the "Initial Catalog" parameter from the connection string in the solution in Visual Studio if you have it defined.