Thursday, 5 June 2014

Entity Framework EF6 and Debugging Errors

I'm building a geo-location Google Glass app today. I want to compare the Glass's location to a set of lat/lon coordinates from an Entity Framework (EF) database - I'm using C# on MSVisStud2013.
Sidebar, the more acronyms and shortened names someone uses, the cooler they are (eg: Banana Republic -> B-Rep. Thanks Paul Thompkins)
Entity Framework First things first, I'm using Code-first approach as opposed to Design-First, and most of the config stuff applies to EF6 onwards so make sure you check your version. Here's some musings/learnings/thoughts from this app: Web.config: If you use EF6 you have the option to do Code-Based Configuration, but what I'm wanting to focus on here is the Web.config or app.config file that specifies the DB. Also of note is that your .config file will override any settings you provide in code. With EF6 (and simple LocalDB or SQL Express setups) your configuration is auto-generated, so when you look online to find help, don't pay attention to the suggestions to add <connectionStrings> tags to connect your db! This is taken care of in the generated <entityFramework> settings.

Debugging Errors
A good programmer must have a process to debug errors that do not (at first) make any sense. A skeleton concept I created today after watching a co-worker debug an error is as follows:
Check errors in
Permissions
Files Existence
Structure (and link/reference errors - especially when moving from local to staging environments)
Packages that need to be included (for eg Know where EntityFramework.dll should exist)

No comments:

Post a Comment