Windows Phone 7 (Mango) Tutorial - 23 - Local Database Support, Configuring Project



Hope you read my previous post on Windows Phone 7.1 (Mango) local database support. If you didn't read the earlier post, you need to read it before reading this one. You can find it here: "Create DataContext". That will give you the basic context about the same.

 

In this post (I will rather calling it as a Tip), we will configure the project by adding the generated DataContext class and in the next post, we will learn what are the various CRUD operations we can do with a sample application. That will give you complete visibility to this new feature implementation.

 

Index - Windows Phone 7 (Mango) Tutorial

 

This post, I am making a short one just to make sure that, you are doing it step-by-step and understand the various process very easily. In this post we will add the generated class into our project and fix all types of error in the solution. As I mentioned in my previous post, I took help from the article made by WindowsPhoneGeek to resolve these issues. That's an awesome post you should read before continuing to the same feature implementation in your project.

 

The issues that you need to Resolve first

Once I added the NorthwindDataContext class file in the project and built, I faced some issues. First thing that I faced was the build error related to the IDbConnection in the constructors. When I searched on net, I found the solution provided by WindowsPhoneGeek and I removed those two constructors as those are not require for Windows Phone 7.

 

WP7.1 LocalDBDemo - Make NorthwindDataContext class Compatible

 

The second issue that I came across is the missing assembly reference for EntitySet and Linq classes. Once you build the solution, you will notice the following errors:

 

WP7.1 - LocalDatabaseDemo - Compile Error

 

 

The no. of errors will depend on the database class generated by the SqlMetal.exe file. To resolve this, you need to add the System.Data.Linq assembly reference from the Add Reference dialog as shown below:

 

WP7.1 LocalDBDemo - Adding System.Data.Linq Assembly Reference

 

Now once you build the solution it will build properly and your project will be ready to do the database operations by using the exposed APIs of that class.

 

Now it's time to create a small demo project to showcase the CRUD operation in the database. We will explore it in depth tomorrow. Till then enjoy learning other articles.

3 comments

  1. I am new to WP7 Development and After reading your post. I followed same steps and got a .cs file, but while adding reference to System.Data.Linq & System.Data.Services.Client I faced a problem. I am not finding the assemblies and Sql CE is installed .
    What to do ??

    ReplyDelete
  2. Hi Abhay,

    You can find the System.Data.Linq.dll in the following path:
    C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Data.Linq.dll

    Let me know, if you face any other problem.

    Regards,
    Kunal

    ReplyDelete
  3. I have the same problem. I cannot find System.Data.Linq...
    Also in the path you write I do not have the folder WindowsPhone7.1 but only WindowsPhone

    ReplyDelete


 
© 2008-2014 Kunal-Chowdhury.com | Designed by Kunal Chowdhury
Back to top