【发布时间】:2022-12-17 18:21:34
【问题描述】:
我正在尝试使用 Visual Studio 发布数据库,该项目没有问题,而且我下载了(数据存储和处理)工具集。然而,每次我尝试部署项目时,我都会收到 SQL:72025 错误。
SQL:72025: 引用的程序集 .DLL 已损坏或无效。
如果我也尝试构建项目,我会收到相同的消息。现在我注意到,通常我们在解决方案资源管理器下点击发布时会弹出一个窗口来配置目标数据库设置,我没有看到那个窗口,而是直接执行项目并失败。
数据库没有什么复杂的,它只是 4 个表和 1 个部署后脚本
这里还有数据库的脚本供您参考
CREATE TABLE [dbo].[RoomTypes] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [Title] NVARCHAR(50) NOT NULL, [Description] NVARCHAR(MAX) NOT NULL, [RoomPrice] MONEY NOT NULL, ) CREATE TABLE [dbo].[RoomDetails] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [RoomTypeID] INT NOT NULL, [RoomNumber] NVARCHAR(10) NOT NULL, [Available] BIT NOT NULL, CONSTRAINT [FK_RoomDetails_RoomTypes] FOREIGN KEY ([RoomTypeID]) REFERENCES RoomTypes(Id) ) CREATE TABLE [dbo].[GuestDetails] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [FristName] NVARCHAR(50) NOT NULL, [LastName] NVARCHAR(50) NOT NULL, [Phone] NVARCHAR(50) NULL, [Email] NVARCHAR(50) NULL ) CREATE TABLE [dbo].[BookingDetails] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [FromDate] DATETIME2 NOT NULL, [ToDate] DATETIME2 NOT NULL, [CheckIn] BIT NOT NULL DEFAULT 0, [TotalCost] MONEY NOT NULL, [GuestId] INT NOT NULL, [RoomId] INT NOT NULL CONSTRAINT [FK_BookingDetails_GuestDetails] FOREIGN KEY ([GuestId]) REFERENCES GuestDetails(Id), CONSTRAINT [FK_BookingDetails_RoomDetails] FOREIGN KEY ([RoomId]) REFERENCES RoomDetails(Id) ) /* Post-Deployment Script Template -------------------------------------------------------------------------------------- This file contains SQL statements that will be appended to the build script. Use SQLCMD syntax to include a file in the post-deployment script. Example: :r .\myfile.sql Use SQLCMD syntax to reference a variable in the post-deployment script. Example: :setvar TableName MyTable SELECT * FROM [$(TableName)] -------------------------------------------------------------------------------------- */ if not exists (Select 1 from dbo.RoomTypes) begin insert into dbo.RoomTypes (Title,Description) values ('King Size Bed', 'A room with a king-size bed and a nice view'), ('Two Queen Size Bed', 'A room with two queen-size beds and a nice view'), ('Executive Suite', 'Two rooms, each with a King-size bed and a nice view'); end if not exists (select 1 from dbo.RoomDetails) begin declare @roomId1 int; declare @roomId2 int; declare @roomId3 int; select @roomId1 = Id from dbo.RoomTypes where Title = 'King Size Bed'; select @roomId2 = Id from dbo.RoomTypes where Title = 'Two Queen Size Bed'; select @roomId3 = Id from dbo.RoomTypes where Title = 'Executive Suite'; insert into dbo.RoomDetails (RoomNumber,RoomTypeID,Available) values ('101',@roomId1,1), ('102',@roomId1,1), ('202',@roomId1,1), ('105',@roomId2,1), ('205',@roomId2,1), ('505',@roomId3,1); end我还检查了下面的帖子,但解决方案对我不起作用,而且出现相同错误的原因也不同。 SQL:72025: The referenced assembly .DLL is corrupt or invalid
错误可能是因为我正在使用 parallels 桌面应用程序吗?我使用的 mac 是 intel mac。
谢谢你们。
【问题讨论】:
标签: c# sql sql-server visual-studio asp.net-core