Invalid object name ‘dbo.xxx’ using MVC3 and SQL Server

When working through the Movies tutorial on the ASP.NET website, I decided that it’d be fun to try to switch the data provider from SQL Compact to the full version of SQL Server 2008. In preparation for the move, I created a new (blank) database and gave the appropriate permissions to my test account. However, after altering my connection string to accommodate SQL Server 2008, I received the following message:

Invalid object name ‘dbo.Movies’.

At first, I thought that my connection string was off, but it turns out that for Entity Framework to automagically create database tables and relationships, the database must not already exist. As such, simply deleting the blank database completely fixed the problem. This, of course, means that your SQL Server user must have db create privileges, which is something that I don’t grant my test account. To get around this, use more powerful credentials for the initial connection that creates the database. Afterwards, you can switch to a more restricted login.

–Adam

Location of Serial Code on UltraSharp Monitors

Can’t seem to find your serial number on your new-ish Dell UltraSharp monitor? On older versions of the UltraSharp line (and probably other Dell monitors), the serial number could always be found on the back of the panel. As it turns out, Dell got fancy with newer models and is now placing the serial on a slide-out card on the left side of the monitor. See the pictures below:

serial card slot

serial card slot

–Adam

The underlying connection was closed: The connection was closed unexpectedly

If you’re attempting to return a LINQ to SQL object using a WCF service and are getting this error, what’s really happening is that .NET can’t serialize your object. This occurs when your LINQ to SQL objects contain circular references (example: customer points to an order, order points back to customer). To get around this, open your data context and in the properties window of the visual designer, set the “Serialzation Mode” option to “Unidirectional”. Thanks to Rick Stahl for his post on the subject.

–Adam

Row not found or changed & LINQ

This is a particularly well-known error (see here, here, and here), but this is the second time that I’ve had to do a search on this error so I thought that I’d post it here so that I can find it more quickly. Anyway, when this error occurs, make sure that the NULL types in the LINQ dbml file match your SQL schema NULL types. Mismatches between the two seem to be a common cause of this error.


–Adam

SaveFileDialog Error When Debugging Silverlight Applications

If you’re having difficulties debugging a section of code that uses the SafeFileDialog.ShowDialog() method, the reason is that Silverlight requires that the ShowDialog() method be called from a user-generated action. For whatever reason, entering into debug mode makes Silverlight think that you are not responding to a user-action, even when you are. To work around this, simply place the breakpoint after you call the ShowDialog() method.

–Adam