Entity Framework 4 CTP and SQL CE 4
Having seen the Scotts' Gu and Hanselman announce the new version of Entity Framework (Magic Unicorn edition, no less), I thought I'd add some of the new 'Code First' goodness to learning / example app.
Here are a few things to be aware of when getting used to EF, especially the new release:
Entity Framework:
- Read the Code First walkthrough and the productivity improvements pages at the same time (or as close as possible). You'll save some time doing this rather than doing things the long way and then cutting out code after reading the second page.
- Pay very careful attention to the code samples, especially where navigation properties are marked as virtual. I didn't, and as a result, ended up debugging some very strange behaviour indeed.
SQL CE:
- Using SQL CE is really easy. Just use the DbContext with no connection specified, and set the default connection as seen in Scott Hanselman's walkthrough. (You'll need to install and reference the runtime library first, of course)
- There seems to be an issue storing datetime values in SQL. I get an"overflow" exception. No idea as of yet how to solve this.
- There doesn't seem to be a good way to browse a SQL CE 4 database. SQL Management studio will attempt to open it, but gives a message to the effect of "I can only understand version 3"