Skip to content
Advertisement

Trying to publish SQL DB on Visual Studio, I keep getting SQL72025 error

I’m trying to publish a database using Visual Studio, the project has no issues plus I downloaded the (Data storage and processing) toolset. Yet I keep getting SQL:72025 error every time I try to deploy the project.

SQL:72025: The referenced assembly .DLL is corrupt or invalid.

I get the same message if I try to build the project too. Now I noticed that usually when we click to publish under the solution explorer a window will pop out to configure the target database setting, I don’t get that window, instead, the project executes directly and fail.

There is nothing complex about the DB, it is just 4 tables and 1 post-deployment script

Screenshot of the solution

Also here is the script for the DB for your reference

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

I also checked the below post but the solution didn’t work for me plus the reason for getting the same error is different too. SQL:72025: The referenced assembly .DLL is corrupt or invalid

Could the error be because I am using parallels desktop app? The mac I am using is an intel mac.

Thank you all.

Advertisement

Answer

I just want to let everyone know that the issue I faced here, the “SQL:72025 ” was due fact that I was using Parallels Desktop for mac. I did the same thing on a windows PC and everything was completely fine. So if anyone out there is planning to use Desktop for mac to develop .net applications, although it’s a very powerful application, I personally suggest sticking with a windows PC to do so.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement