# Friday, 27 September 2013

Did you ever get lost in the myriad of SDKs and Microsoft Nuget packages? If you did then let me tell you a secret: you’re not alone. Luckily Microsoft listens very carefully to feedback from their users and community and has put a couple of pages together with some handy overviews:

Grz, Kris.

MSDN | Nuget | SDK
Friday, 27 September 2013 13:11:23 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 07 May 2012

Today I was trying to run a sample application for VS11 Beta that I found online: Download Hands-on Lab Source Files. However when trying to run the pages I encountered the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Looking into the inner exception:

ANetworkRelatedErrorOccured

gave me the following:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).

Ouch!

Well, what I could’ve done is trying to fiddle around with settings of SQL Server, trying to get it right and working. However I noticed that Entity Framework was being used and in the code I found this little piece:

public class ProductsContext : DbContext
{
    public ProductsContext() : base("WebFormsLab-Products")
    {
    }

    public DbSet<Category> Categories { get; set; }
        
    public DbSet<Product> Products { get; set; }
        
    public DbSet<Customer> Customers { get; set; }
}

Inherits from DbContext? Aha, that’s interesting. Now, let me see if we can get SQL Server Compact into play. Well, we can. There’s a nice Nuget package available:

PM> Install-Package EntityFramework.SqlServerCompact

This will update the web.config as well as besides downloading the package. Now running the same page again it shows the information nicely instead of giving that nasty error. Also it generated a new database file in the App_Data subfolder:

sdfcreated

Super!

Conclusion: SQL Server Compact to the rescue together with Entity Framework Code First. It’s easy to integrate via Nuget and it simply works (disclaimer: on this machine).

Grz, Kris.

Monday, 07 May 2012 20:12:44 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  |