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.
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:
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:
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.