Two Ways to Create a Database for Your Mango App
So you are working on a Windows Phone 7 App and need to create a database to store application data. There are plenty of resources out there to help you get started, but this recent Mango Database tutorial by Jerry Nixon, a Microsoft Developer Evangelist, is particularly clear, to the point, and chock full of useful external resources.
Part 1 will flex your SQL chops as you utilize the Entity Framework's Code First development pattern to create your classes first, so that they can then be mapped onto an existing database or used to generate a fresh database schema. Don't forget to take advantage of the "Do better" sections to optimize what you've put together. For example, Jerry has the following advice for efficiently dealing with frequent queries:
One of the easiest ways to optimize the performance of an update operation on a table is to add a version column. This optimization is specific to LINQ to SQL for Windows Phone. This can yield a significant performance improvement for large updates. More here.
Jerry is approaching this tutorial like a true educator. How do I know? At the end of the post he puts himself in the student's shoes and launches a preemptive strike against the questions his lesson is likely to raise. For each question you'll find a link to the relevant information straight from Microsoft.
Part 2 of the tutorial approaches the same project from a different angle. Rather than the Code First method, you can opt to use Visual Studio create the database first. According to Jerry, this method is more intuitive at design-time but unfortunately requires you to jump through some hoops:
It seems most intuitive to use the database visual designer at design-time. It is most unfortunate that this method is the least supported. Moreover, it seems just messy that we must drop to the Visual Studio DOS prompt and use SQLMetal to get it fully working.
If you're working on a Windows Phone app, this tutorial is a great resource not only for producing results but also for getting you to think about methodologies. Whether you prefer to code first or design first, Jerry's got you covered.
source for part 1: http://blog.jerrynixon.com/2011/11/mango-sample-database-part-12.html
source for part 2: http://blog.jerrynixon.com/2011/11/mango-sample-database-part-22.html