entity framework - EF5 generates SQL Server CE constraints with dot in name -


i building .net disconnected client-server application uses entity framework 5 (ef5) generate sql server ce 4.0 database pocos. application allows user perform bulk copy of data network sql server client's sql server ce database. (very) slow, due constraints , indexes created ef5. temporarily dropping constraints , indexes reduce 30-minute wait 1 minute or less.

before starting bulk copy, application executes queries drop constraints , indexes sql server ce tables. however, commands fail, because ef5 created constraint names include table schema name, dot, , table name. dot in constraint name causing drop command fail, due parsing issue.

for example, poco customer creates table dbo.customer primary key constraint pk_dbo.customer_id. database performs expected.

however, upon executing non-query:

 alter table customer drop constraint pk_dbo.customer; 

sql server compact ado.net data provider returns error:

there error parsing query.
[ token line number = 1, token line offset = 57, token in error = . ]

of course, using secondary datacontext object not have foreign keys generate database without constraints, , add them later works; but, requires maintaining 2 datacontext objects , not forgetting keep both updated. therefore, looking 1 of 2 solutions:

  1. compose drop statement in such way . character parsed

  2. prevent ef5 using . character in constraint , index names

thank in advance help!

wrap bad boy in []. tells parser inside key name.

alter table customer drop constraint [pk_dbo.customer]; 

should run fine. wrap every identifier in brackets avoid exact issue. write query this.

alter table [customer] drop constraint [pk_dbo.customer]; 

i think it's more readable way because can instantly see identifiers.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -