我有一个在VS 2017中创建的数据库项目。我对其进行了重大更改,包括将列移动到其他表等。
然后我删除了bin和obj文件夹。我还去了C:\ Users \ david \ AppData \ Local \ Microsoft \ Microsoft SQL Server本地DB \ Instances \ ProjectsV13,在正在运行的进程中杀死了sqlserver.exe,然后删除了该文件夹中的所有文件。
构建时,我仍然得到以下信息:
------ Build started: Project: Database1, Configuration: Debug Any CPU ------
Loading project references...
Loading project files...
Building the project model and resolving object interdependencies...
Validating the project model...
Writing model to C:\git\Store\Database1\obj\Debug\Model.xml...
Database1 -> C:\git\Store\Database1\bin\Debug\Database1.dll
Database1 -> C:\git\Store\Database1\bin\Debug\Database1.dacpac
------ Deploy started: Project: Database1, Configuration: Debug Any CPU ------
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72023: The database containment option has been changed to None. This may result in deployment failure if the state of the database is not compliant with this containment level.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Organization].[BillingId] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Person].[CompanyName] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Person].[IsBilling] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Person].[IsEnabled] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[BillingErrorDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[BillingMode] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[BillingStatus] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[ChargeToken] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[DeactivateDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[DeleteDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[Discount] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[NextBaseBillingDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[NextOverageBillingDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Warning: SQL72015: The column [dbo].[Subscription].[ShutoffDate] is being dropped, data loss could occur.
C:\git\Store\Database1\bin\Debug\Database1.sql: Error: SQL72031: This deployment may encounter errors during execution because changes to [dbo].[Subscription].[ApiKey1] are blocked by [dbo].[Subscription].[IX_Subscription_ApiKey]'s dependency in the target database.
C:\git\Store\Database1\bin\Debug\Database1.sql: Error: Deploy72002: Plan verification encountered errors; deployment cannot continue.
Done building project "Database1.sqlproj" -- FAILED.
Build FAILED.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
不再有IX_Subscription_ApiKey(已被IX_Subscription_ApiKey1代替)。
subscription.sql文件就在其中(“ 123”和“ 4546”正好可以尝试运行):
CREATE TABLE [dbo].[Subscription] (
[SubscriptionId] BIGINT IDENTITY (1, 1) NOT NULL,
[OrganizationId] BIGINT NOT NULL,
[SubscriptionName] NVARCHAR (255) NOT NULL,
[ApiKey1] CHAR (36) NOT NULL DEFAULT '123' ,
[ApiKey2] CHAR (36) NOT NULL DEFAULT '4546' ,
[IsEnabled] BIT CONSTRAINT [DF_Subscription_Enabled] DEFAULT ((1)) NOT NULL,
[IsActive] BIT CONSTRAINT [DF_Subscription_Active] DEFAULT ((1)) NOT NULL,
[AccruedRtusThisMonth] BIGINT CONSTRAINT [DF_Subscription_PendingRtus] DEFAULT ((0)) NOT NULL,
[BilledRtusThisMonth] BIGINT CONSTRAINT [DF_Subscription_PaidRtus] DEFAULT ((0)) NOT NULL,
[OverageChargesThisMonth] MONEY CONSTRAINT [DF_Subscription_OverageChargesThisMonth] DEFAULT ((0)) NOT NULL,
[PricingMode] TINYINT NOT NULL,
[PricingPlanId] BIGINT NULL,
[MaxAdditionalMonthlyCharge] MONEY NOT NULL,
[XtraAutoTags] INT CONSTRAINT [DF_Subscription_XtraAutoTags_1] DEFAULT ((0)) NOT NULL,
[EndFreeUse] SMALLDATETIME CONSTRAINT [DF_Subscription_EndFreeUse_1] DEFAULT (getutcdate()) NOT NULL,
[Created] SMALLDATETIME CONSTRAINT [DF_Subscription_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[TS] ROWVERSION NOT NULL,
CONSTRAINT [PK_Subscription] PRIMARY KEY CLUSTERED ([SubscriptionId] ASC),
CONSTRAINT [FK_Subscription_PricingPlan] FOREIGN KEY ([PricingPlanId]) REFERENCES [dbo].[PricingPlan] ([PricingPlanId]),
CONSTRAINT [FK_Subscription_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([OrganizationId])
);
GO
CREATE NONCLUSTERED INDEX [IX_Subscription_OrganizationId]
ON [dbo].[Subscription] ([OrganizationId] ASC);
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Subscription_ApiKey1]
ON [dbo].[Subscription]([ApiKey1] ASC);
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Subscription_ApiKey2]
ON [dbo].[Subscription]([ApiKey2] ASC);
GO
CREATE NONCLUSTERED INDEX [IX_Subscription_EndFreeUse]
ON [dbo].[Subscription]([EndFreeUse] ASC);
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Subscription_Name]
ON [dbo].[Subscription]([SubscriptionName] ASC);
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'The primary key',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'SubscriptionId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'FK to the Organization that owns this credit card',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'OrganizationId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'The key supplied to the engine & AutoTag',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'ApiKey1'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'Alternative key. Either can be used.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'ApiKey2'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'The customer sets to false to turn this off.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'IsEnabled'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'Windward sets to false to force this off.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'IsActive'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'RTUs that have accrued so far this month.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'AccruedRtusThisMonth'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'RTUs that have been paid for so far this month. Includes the RTUs that come with the monthly plan.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'BilledRtusThisMonth'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'How much has accrued in overages so far this month.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'OverageChargesThisMonth'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'The maximum allowed to charge for overages each month. Reports are disallowed after hitting this maximum.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'MaxAdditionalMonthlyCharge'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'Number of additional AutoTags purchased.',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'XtraAutoTags'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'Date that free use (trial) ends',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'EndFreeUse'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'Date this record was created',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'Created'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'The pricing plan on. 1 = bronze, 2 = silver, 3 = gold, 4 = platinum, 255 = custom',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'PricingMode'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
@value = N'FK to the pricing plan if a custom plan',
@level0type = N'SCHEMA',
@level0name = N'dbo',
@level1type = N'TABLE',
@level1name = N'Subscription',
@level2type = N'COLUMN',
@level2name = N'PricingPlanId'
为什么不开心?
谢谢-戴夫
答案 0 :(得分:0)
我知道了。打开SSMS并连接到(LocalDb)\ ProjectsV13(用您的数据库名称替换ProjectsV13)。在我的情况下,数据库位于C:\ Users \ david \ AppData \ Local \ Microsoft \ Microsoft SQL Server本地DB \ Instances \ ProjectsV13中,名称来自该文件夹。
打开后,在SSMS中选择数据库并删除它。一旦您知道该怎么办,便是非常简单的解决方案。
顺便说一句-连接到本地主机不会给您本地DB。只是(localdb)不起作用。