We had the same problem - dacpac deploys would perform fine when running tests but run very slow while debugging tests.
In my case, the dacpac had a bunch of .sql scripts which seeded some test data into the database. One of these scripts was autogenerated from SSMS, so it was 40,000 lines long, something like this:
INSERT [dbo].[Resource] ([CategoryId], [StoreCode], [LocaleCode], [ResourceName], [ResourceText]) VALUES (1, N'AU', N'en-AU', N'AD', N'Andorra')
GO
INSERT [dbo].[Resource] ([CategoryId], [StoreCode], [LocaleCode], [ResourceName], [ResourceText]) VALUES (1, N'AU', N'en-AU', N'AE', N'United Arab Emirates')
GO
INSERT [dbo].[Resource] ([CategoryId], [StoreCode], [LocaleCode], [ResourceName], [ResourceText]) VALUES (1, N'AU', N'en-AU', N'AF', N'Afghanistan')
etc, for 40,000 lines, i.e. 20,000 INSERT
AND GO
statements.
I was able to see that script was causing the problem by querying my dbo.Resource table while I was debugging and seeing that the script in question was executing slowly, as the number of rows in that table was still increasing.
I rewrote that script using some Notepad++ macros to have fewer INSERT
statements, and to insert 1000 rows on each INSERT
, e.g.
INSERT [dbo].[Resource] ([CategoryId], [StoreCode], [LocaleCode], [ResourceName], [ResourceText]) VALUES
(1, N'AU', N'en-AU', N'AD', N'Andorra'),
(1, N'AU', N'en-AU', N'AE', N'United Arab Emirates'),
(1, N'AU', N'en-AU', N'AF', N'Afghanistan'),
...
GO
and that fixed the problem.