I'm working with EF5 using the model-first approach. I've designed the model and executed the SQL script which generated the corresponding database (using "Generate Database from Model").
I then had to use UDFs to calculate a couple of column values (which requires dropping and re-adding the columns). I've done that in SSMS and then used "Update Model from Database..." to reflect the changes in the model.
Till this point, everything worked great.
But from this point, every time I update the database from the model (as described above), the computed columns are overridden with "standard" columns.
For example, following is an excerpt from the SQL script generated by EF:
-- Creating table 'ShipmentSet'
CREATE TABLE [dbo].[ShipmentSet] (
[Id] int IDENTITY(1,1) NOT NULL,
[Details] nvarchar(128) NOT NULL,
[BarcodeValue] nvarchar(32) NOT NULL,
[ExecutionDate] datetime NOT NULL,
[RouteId] int NOT NULL,
[IsLocationBarcodeRequired] bit NOT NULL,
[IsPending] bit NULL,
[LastAction] tinyint NULL
);
GO
The two last columns are computed columns, and their StoreGeneratedPattern
in the model is defined as Computed
.
Is there a way to add the computed column formulas in the model? The SQL script drops the tables then re-creates them, so "ignoring" these columns won't do.