Entity Developer Version 5.7.576 (26-Mar-15) - Don`t drop default constraint (MS SQL)

Entity Developer Version 5.7.576 (26-Mar-15) - Don`t drop default constraint (MS SQL)

Postby AKRRKA » Thu 02 Apr 2015 10:02

Entity Developer Professional Version 5.7.576 (26-Mar-15) - Don`t drop default constraint (MS SQL)

Hello.

Have a problem.
When create into table 'TransTypes' field 'IsVoltage' with type bool (System.Boolean) and defaul value 'True', for MS SQL Server, generated this code:
Code: Select all
--
-- Creating a table dbo.TransTypes
--
CREATE TABLE dbo.TransTypes (
   TransTypeId INT NOT NULL IDENTITY,
   Name VARCHAR(8000) NOT NULL,
   IsVoltage BIT NOT NULL DEFAULT ('True'),
   TrRatio INT DEFAULT 1,
   CONSTRAINT PK_TransTypes PRIMARY KEY (TransTypeId)
)


This correct create table into databse.
http://rghost.ru/8fFWSR9h4/image.png
Image
SQL Server Management Studio show this create sript^

Code: Select all
USE [cedatabase]
GO

/****** Object:  Table [dbo].[TransTypes]    Script Date: 04/01/2015 16:43:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TransTypes](
   [TransTypeId] [int] IDENTITY(1,1) NOT NULL,
   [Name] [varchar](8000) NOT NULL,
   [IsVoltage] [bit] NOT NULL,
   [TrRatio] [int] NULL,
CONSTRAINT [PK_TransTypes] PRIMARY KEY CLUSTERED
(
   [TransTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[TransTypes] ADD  DEFAULT ('True') FOR [IsVoltage]
GO

ALTER TABLE [dbo].[TransTypes] ADD  DEFAULT ((1)) FOR [TrRatio]
GO


How can you see for filde IsVoltage created default constraint. And for this constraint generated random name 'DF__TransType__IsVol__0A338187'.
Attention! Name is random (see __0A338187)!

And when i drop field from table, and apply change to database from function update database from model, have a problem.
Because generated script:

Code: Select all
--
-- Altering a table dbo.TransTypes
--
ALTER TABLE dbo.TransTypes
   DROP
      COLUMN IsVoltage,


http://rghost.ru/8vNkylzVd/image.png
Image

But conctraint don`t get delete this field!

http://rghost.ru/8qzShmnNZ/image.png
Image

I had to come up with a hack.
Code: Select all
--
-- Drop  default constraint from table dbo.TransTypes
--
DECLARE @SQL varchar(MAX)

SELECT @SQL = 'ALTER TABLE TransTypes DROP CONSTRAINT '+
   OBJECT_NAME(OBJECT_ID)
   FROM sys.objects
   WHERE type_desc LIKE 'DEFAULT_CONSTRAINT'
   AND (OBJECT_NAME(parent_object_id) = 'TransTypes')
   AND (OBJECT_NAME(OBJECT_ID) like '%IsVol%')

IF (NOT (@SQL IS NULL))   EXEC(@SQL)


--
-- Altering a table dbo.TransTypes
--
ALTER TABLE dbo.TransTypes
   DROP
      COLUMN IsVoltage,


But this not resolve problem into Entity Developer.

PS: Model-First mode. Use generated script for create diff sql for update database to new version.
PPS: Entity Developer from LinqConnect Professional Version 4.4.717 (26-Mar-2015).
AKRRKA
 
Posts: 194
Joined: Thu 26 Jan 2012 15:07
Location: Russia

Re: Entity Developer Version 5.7.576 (26-Mar-15) - Don`t drop default constraint (MS SQL)

Postby MariiaI » Fri 03 Apr 2015 06:13

Thank you for the report on this. We have reproduced the issue. We will investigate it more clearly and inform you about the results as soon as any are available.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)