I want to programmatically create the database create script for my EF 4.3 Code-First database. The database creates just fine using the standard DatabaseInitializer mechanisms, but the following code fails:
using(var dc = new MyContext())
{
var objContext = (IObjectContextAdapter)dc;
var script = objContext.ObjectContext.CreateDatabaseScript();
}
The exception I get is:
The store generated pattern 'Computed' is not supported for properties that are not of type 'timestamp' or 'rowversion'.
I do have a Computed column defined of type "string" but like i said, the database creates fine when created via the built-in DatabaseInitializer. Oddly enough, the resulting schema using this method doesn't actually create a computed column.
As to why I'm doing this, I have a script that runs post-create that drops this column and creates a bonafide computed column. Without specifying the column as computed in the EF mapping, it will attempt to assign that column a value upon inserts, which then fails.