I'm currently using Visual Studio to develop an ASP.NET/C# web application that relies on a SQL Server database for the data behind. From the moment I originally created the Data Connection through VS, I've gone back and changed certain things in the DB (certain column types, added test rows, etc) through SQL Server Management Studio. However, none of these changes are reflected in the VS application, which is a pain because I am constantly getting errors because of the mismatch. For example, I tried to insert a string into a column that was originally an int and I get an error when trying to process the query through my code behind, even though the actual DB lets me run the query just fine through SQL Server Manager.
This mismatch is so bad that if I run the same query (SELECT * FROM Project) on both SQL Server Manager and Visual Studio I get completely different results: SQL Server Management Studio vs Visual Studio
I've tried refreshing my connection on Server Explorer to no end and even created a new connection string on Web.config to see if this would somehow fix it, but nothing seems to work. I found an article that explains that VS creates a local version of the DB during the build, but it seems like the solution it provides only works for non-ASP.NET projects because I don't have a bin/Debug DB.
Any suggestions to get Visual Studio to reflect the latest version of my schema/data? Thank you!
From your example files, you are working on two different databases.
Execute the following command in SQL Server Management Studio and in Visual Studio. You will likely see that the filenames listed are different.
exec sp_helpfile
If so, then you are not connecting to the same server/database in both environments. You can click on the database in Visual Studio to see the "Connection string" in the Properties window. Check it against your web.config connection string.
Related
tried looking at other examples on this and am a bit confused. I have 2 web servers that are load balanced and a sql server box (sql 2012). my cube is created on the sql server box (i see it in management studio). when i try to access via my asp.net page i receive the above error.
now, i see the msolap110.dll in C:\Program Files (x86)\Microsoft Analysis Services\AS OLEDB\110 on the sql box. do i need to do something permission wise with the dll or something? do i need to install analysis services on the web server? is there a specific port or something (doubtful as sql is running fine).
connection string is as follows:
"Provider=msolap;Data Source=;Initial Catalog=AutoOLAPAW;Cube Name=SampleCube;"
going to try to force to use MSOLAP.5 but waiting on a republish from our security/deployment group.
this all works fine in dev but my (more secured/stripped down) prod/qa is where i'm seeing the issue. using iis7 on both.
If you are using ADOMD.NET then either set CopyLocal=True on that reference on your ASP.NET source code so Microsoft.AnalysisServices.AdomdClient is deployed with the web app... Or install SQL_AS_ADOMD.msi from:
https://www.microsoft.com/en-us/download/details.aspx?id=49999
If you are using OLEDB then install SQL_AS_OLEDB.msi from that same link.
If you don’t want the SQL2012 version but want the latest then install from here and use Provider=MSOLAP in the connection string (instead of a number like MSOLAP.5).
I'm comparing a database in a local SQL Server 2014 instance against an SSDT database project.
I have done previous comparisons and they have worked fine.
At times I also change the project database target from SQL Server 2014 to SQL Azure to push changes to a SQL Azure database.
I made sure the project was set to SQL Server 2014 before trying to perform the most recent comparison and update.
Unfortunately the error message gives no indication of what went wrong, where it went wrong, or where to find more information.
Further more a quick Google for the error text gives no results! It seems no one has even mentioned this error before on the internet.
(That's not quite true any more. You can now find where I'm asking about this issue on the MSDN forums, currently with no response.)
Does anyone know if this error message relates to something specific? Or is there a way to find out more information from a log? How do I debug, and ideally resolve this?!
For now I have deleted all the sql files, and the cache file (dbmdl) from the project and then performed another compare/update.
This allows me to continue working, but it's an unsatisfying resolution.
I had this problem:
Using SSDT 15.1 in Visual Studio 2017
After performing a Schema Comparison which compared a localhost SQL Server 2016 database with an open SSDT project.
When a Temporal Table in the localhost SQL Server had been renamed but the SSDT project had the old name.
There were many other changes to other normal tables, however - like added columns, new foreign-key constraints, etc.
I tried performing a Clean Project, deleting the obj and bin directories in the SSDT project, and reloading the solution - none worked.
I re-ran the comparison and deselected all changes detected in the Temporal Table and clicked Update to apply all of the other changes and this succeeded. I then clicked Compare again and this no-longer showed the renamed temporal table but did show the automatically defined index on the temporal table's history table (which was now correctly named in SSDT but not the localhost SQL Server). I manually renamed the index in the localhost SQL Server using SSMS (not SSDT) and re-ran the comparison and it detected no changes. Phew!
It looks like as of mid-2019 that the current build of SSDT still has some issues with Temporal Tables.
I had received same problem while working on Visual Studio 17.
I just closed the solution and visual studio and re-opened visual studio with "Run As Administrator" and this resolved the issue.
I experienced the same error message when was trying to compare DB (compatibility mode SQL Server 2012 (110)) to DB project (target platform SQL Server 2012). Following actions worked out for me:
Clean DB project
Set both DB and DB project to SQL Server 2014. Compare again, you'll have the same error
Set both DB and DB project to SQL Server 2012. Compare again, no error message any more.
I used:
Microsoft Visual Studio Enterprise 2015 Version 14.0.23107.0 D14REL
SQL Server Data Tools 14.0.50730.0
I had the same error on Project Database 2008.
I converted all the database projects from .NET 4.5 to .NET 4.0 and it worked.
For me this problem was being caused by a new schema that I had added to the database for testing. Dropping the schema resolved the issue for me.
Same error, trying to update the db project. I had its Target platform set to SQL Server 2016 and Target framework set to .Net Framework 4.7.2.
What worked for me was to change the Target framework to .Net Framework 4, then compared and updated a few changes, and it worked. Then set the Target framework again to 4.7.2, compared and updated the rest of the changes. It's been working ever since.
We are in the process of developing a new site that we plan to host on Azure. None of us have done this before, so it has raised some interesting challenges.
First, we are using code first and using migrations to update the database. We were having some issues figuring out how to deploy the database to Azure, so we ended up creating a database project.
There are a bunch of Azure specific issues with deployment, and you will get errors if you don't rectify all the valid SQL that Azure doesn't allow you to use.
It seemed to me that you should be able to do code first on the azure site just like we did on the local site, and I found This article that seems to address the issue.
What I am wondering though, is best practices.
I would assume we don't need database projects anymore, but I am not
sure about that. What is the best practice for managing databases
with Visual Studio 2013 and code first.
The approach in the article above seems fine for a system in
pre-production, but once a system is in production and has live
data, is this a recommended approach?
How do you protect yourself from mistakes like somebody accidentally changing a
setting that tells Visual Studio to recreate the database?
Any thoughts or ideas would be appreciated.
First i would like to state from my understanding, when using Entity Framework and you have Enabled Migration, it's only meant for development and it is recommended that you set it to false when deploying your code.
As for deploying to Microsoft Azure, i have only done this using Visual Studio Team Services. The thing about Code-First is that you have no Sql Queries and the database is not deployed right away. So here is what i have done in the past,
Create a blank Sql Query in SQL Management Studio
In Visual Studio Server Explorer expand your database for the
project to table level
Right click on each table and select "Show Table Definition" I wish
we could do this at Database level.
Copy and past the T-SQL to a blank Sql file in SQL Management
Studio. Note that all table queries can fit in one
file, just have to follow T-SQL rules. Connect to your Azure
Database Instance using SQL Management Studio.
Run the SQL Query against the database on Azure. Note that the
sample data you had used in developemnt will not be on your Azure
database at this moment, you will have to create an insert T-SQL and
run it against the Azure database.
Also make sure that your app has the right connection string when deploying to Microsoft Azure and it should connect to you database just fine.
I'm trying to use a Data-Tier application involving a linked server and running into an odd problem.
Here's what I have:
1) A VS2010 solution which includes a Data-Tier project.
2) The Data-Tier project targets an SQL 2008 R2 server.
3) The SQL server has a working linked server connection to an Oracle database.
4) Views within the Data-Tier project reference the linked server using OPENQUERY
The linked server connection is valid, running queries against it on the server work fine, and creating the views directly on the server works fine as well.
However, whenever I attempt to build my Data-Tier application I get the following error:
SQL03006: View: [dbo].[vwMyExampleView] has an unresolved reference to object [MyExampleLinkedServer].
Essentially the problem is that the SQL Server Database project doesn't have a way to resolve the Link to the Oracle database's tables.
I had a similar problem when trying to reference a table in a different database on the same server. In my case I was using SQL Server for both databases, and created a database project for the other database, added it to the solution for the first project, then created a reference to the second project from the first. I also used SQLCMD variables in synonyms so that I would be able to change the synonym, and all my proc and view references would not need to be updated.
I'm not sure this will work between SQL Server and Oracle since the Visual Studio database edition only supports SQL Server. (AFAIK) You may be able to find a solution by creating a .dbschema file and adding the Database reference to your SQL Server project.
More details can be found at this link:
http://msdn.microsoft.com/en-us/library/bb386242.aspx
In SQL 2012, just add new item-> Server Objects - > LinkServer, add the sp code that creates link server, you are good to go
I come from a linux/apache/php/mysql background. For my current project, I am forced to write web services using ASP.NET. I have installed visual studio and created an ASP.NET web service project. The web service I'm creating will use a SQL database backend. I see that visual studio installed "SQL Server Express 2008." I can see that there is a service called "SQL Server (SQLEXPRESS)" that is running. My question is, how do I run queries against this database? Where's the front end? What tool do I use to create databases and tables? Is there something else I have to install?
I feel completely lost and my google-fu fails me. There are so many different SQL products from microsoft that I can't tell what is the easiest path to just having a simple database with tables I can query from my development machine. With MySQL, I would install the MySQL database, download MySQL query browser and start firing queries at it. How can I do that with Visual Studio/SQL Server Express?
You can download SQL Server Management Studio from here. This is the GUI for working with SQL Server. It will let you create databases, tables, stored procedures, etc. as well as writing queries and manually edit data in the tables.
Aside from SQL Server Management Studio, you can use the Server Explorer tab in Visual Studio (by default on the right side, next to Solution Explorer) to add a data connection. You can do most of the most common database tasks (create/query tables, create views, etc) from there.
there's a command line tool that installs with SQL Server (all versions) called SQLCMD.exe, should be in your install path.
Visual Studio also lets you create dbs, run queries, look at table structures and data (including creating and deleting them, etc), you do that by opening your Server explorer window and making a connection to your local instance (.\SQLExpress by default).
Finally, as the other person mentioned, SQL Server Management Studio Express is a free download, and well worth the time it takes to install.