2010/05/31

Don’t use ‘entities’ as the namespace for an Entity Framework model

In a .NET 3.5 project I created an Entity Framework model and wanted to consolidate the generated classes into a namespace that seemed appropriate to categorize them.  So I chose the namespace ‘entities’.  Apparently that’s an unwritten no-no and I’m the only one who’s run into it (or at least have no shame in admitting I ran into this error).  The problem is that it causes an “UpdateModelFromDatabaseException” error when trying update the model from the database (like you couldn’t guess from the exception name…).  Outside of that issue everything seemed to be working correctly with the model.  All database calls were working, no compile errors, no odd behaviors in the classes themselves.  It just wouldn’t update the model.  So when googling didn’t turn up any answers, I turned to StackOverflow.  Like a number of my questions, it wound up not getting any answers (and very few views at that).  Thus it came time to start experimenting by repeating the steps in creating the model but changing small things.  After a few hours it wound up being the namespace name.

So like title says: Don’t use ‘entities’ as the namespace for an Entity Framework model.

Post a Comment