Row size exceeds the maximum row size of 8060 in Entity Framework.

entity-framework sql-server sql-server-2008

Question

I have a thing with a binary datatype and a matching binary datatype.varbinary(max) in SQL Server's column. EF produces this

CREATE TABLE [dbo].[Attachments] 
(
    [Id] INT IDENTITY(1,1) NOT NULL,
    [FileName] NVARCHAR(255) NOT NULL,
    [Attachment] VARBINARY(MAX) NOT NULL
);

When I make calls,.SaveChanges() I get a mistake from Entity Framework:

Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060

Although there are many examples of that mistake on Google, I'm not sure why I keep receiving it. Shouldn't SQL Server and Entity Framework handle this?

Richard

1
6
10/16/2017 10:00:43 AM

Accepted Answer

The only scenario in which I can see you encountering this mistake with that table design is if you had had a huge fixed width column but have since removed it.

CREATE TABLE [dbo].[Attachments] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [FileName] nvarchar(255) NOT NULL,
    [Attachment] varbinary(max) NOT NULL,
    Filler char(8000),
    Filler2 char(49)
);

ALTER TABLE  [dbo].[Attachments] DROP COLUMN Filler,Filler2

INSERT INTO [dbo].[Attachments]
([FileName],[Attachment])
VALUES
('Foo',0x010203)

That Gives

Msg 511, Level 16, State 1, Line 12 Cannot create a row of size 8075 which is greater than the allowable maximum row size of 8060.

Try rebuilding the table if this is the case.

ALTER TABLE [dbo].[Attachments] REBUILD 
18
10/3/2011 10:45:30 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow