Static Data for a Table with a Database Identity

Feb 26, 2011 at 6:51 PM

When adding Static Data to an Entity that has a primary key is Database Generated, the Static Data input screen has an option to enter the Primary Key field.
Since it's generated by the database I left it blank, which results in this fautly SQL in CreateSQL.sql.
See below, where XXX is the syntax error in   where ([ApplicationId] = XXX  ))

It would make more sense to me if the Primary Key was generated by the DB, but I can see that there might be case where the developer does want to specify.
Please could you confirm what the design intention was.


--Static Data For Version
--Generated on 2011-02-26 19:30:32
SET identity_insert [dbo].[Application] on
if not exists(select * from [dbo].[Application] where ([ApplicationId] = )) INSERT INTO [dbo].[Application] ([ApplicationDescription],[ApplicationId],[ApplicationName]) values ('Application1 Descr',0,'App1')
if not exists(select * from [dbo].[Application] where ([ApplicationId] = )) INSERT INTO [dbo].[Application] ([ApplicationDescription],[ApplicationId],[ApplicationName]) values ('Application2 Descr',0,'App2')
SET identity_insert [dbo].[Application] off

Mar 26, 2011 at 3:58 AM

This is done this way because this script is run each time you update a database this script file is run. We key of the PK and decide whether to insert this database row. This is by design. If you add more static data in the future it will be added but the existing data rows will nto be touched. This is why this mechanism is done this way. I know identity PK are generated by the DB but the way we have this setup makes it easy to manage static data.