views:

10

answers:

1

I'm doing a simple test in Visual Studio 2010 using the ADO.NET Entity Framework, and the very first table's put a snag for me to hit: there are a couple of data tracking columns that have no use in the application (they're used for auditing), but EF is forcing me to map them because they're non-nullable and EF claims that they have no default value.

They do, however, all have default value constraints. There's no need for me to map these columns (or deal with them in EF at all), yet I can't seem to find a way around this.

Is there a way to get EF to recognize that a column has a default value and not map it at all?

+1  A: 

There are two ways:

  1. Create your EF model on a DB which doesn't have those columns. The "real" DB will work fine 1t runtime.
  2. Edit the EDMX and set StoreGeneratedValue in SSDL. The EF still maps these, but won't complain when they're not filled in.

Pick whichever method suits you.

Craig Stuntz