NotSupportedException: Data type 'varchar' is not supported in this form

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
smlemmon
Posts: 7
Joined: Sat 26 Jan 2013 09:51

NotSupportedException: Data type 'varchar' is not supported in this form

Post by smlemmon » Mon 13 Jun 2016 18:41

Hi,

I have been a long term user of Entity Developer but only just started using it with EF Core 1.0 RC2

Unfortunately so far, I have had no success.

After reverse engineering our database using Entity Developer for EF Core, the first issue I encountered was StackOverflow whenever I tried to retrieve data from any table in the database. I tried it with many but without success. I assumed this may be some sort of recursive relationship, so deleted all my entities from the model and just reverse engineered one of the tables to keep things simple,

Now, whenever I try to retrieve from this table I get another error:-

NotSupportedException: Data type 'varchar' is not supported in this form. Either specify the length explicitly in the type name, for example as 'varchar(16)', or remove the data type and use APIs such as HasMaxLength to allow EF choose the data type


I have looked through the generated code and it appears to be OK, however looking at a post on the EF Core project site, I am not sure if the syntax is correct or not for the varchars.

https://github.com/aspnet/EntityFramework/issues/4759

So ultimately, I havent a clue whether this is a EF Core or an Entity Developer issue, but I am just about at the point of giving up.

Here is the mapping code that Entity Developer created...

private void TermMapping(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Term>().ToTable(@"TERMS", @"dbo");
modelBuilder.Entity<Term>().Property<int>(x => x.TrmId).HasColumnName(@"TRM_ID").HasColumnType(@"int").IsRequired().ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmClientId).HasColumnName(@"TRM_CLIENT_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<System.DateTime>>(x => x.TrmVehicleFromDate).HasColumnName(@"TRM_VEHICLE_FROM_DATE").HasColumnType(@"datetime").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<System.DateTime>>(x => x.TrmVehicleDiscontinuedDate).HasColumnName(@"TRM_VEHICLE_DISCONTINUED_DATE").HasColumnType(@"datetime").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapManufacturerId).HasColumnName(@"TRM_CAP_MANUFACTURER_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapRangeId).HasColumnName(@"TRM_CAP_RANGE_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapModelId).HasColumnName(@"TRM_CAP_MODEL_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapTrimId).HasColumnName(@"TRM_CAP_TRIM_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapDerivativeId).HasColumnName(@"TRM_CAP_DERIVATIVE_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmCapId).HasColumnName(@"TRM_CAP_ID").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<string>(x => x.TrmCapCode).HasColumnName(@"TRM_CAP_CODE").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(40);
modelBuilder.Entity<Term>().Property<string>(x => x.TrmVehicleDisplay).HasColumnName(@"TRM_VEHICLE_DISPLAY").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(255);
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmOptionCategoryCode).HasColumnName(@"TRM_OPTION_CATEGORY_CODE").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<int>>(x => x.TrmOptionCode).HasColumnName(@"TRM_OPTION_CODE").HasColumnType(@"int").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmActive).HasColumnName(@"TRM_ACTIVE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<decimal>>(x => x.TrmValue).HasColumnName(@"TRM_VALUE").HasColumnType(@"decimal").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmAdditionToDealerDiscount).HasColumnName(@"TRM_ADDITION_TO_DEALER_DISCOUNT").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmInLieuOfDealerDiscount).HasColumnName(@"TRM_IN_LIEU_OF_DEALER_DISCOUNT").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmManufacturerDiscountOnInvoice).HasColumnName(@"TRM_MANUFACTURER_DISCOUNT_ON_INVOICE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmManufacturerDiscountOffInvoice).HasColumnName(@"TRM_MANUFACTURER_DISCOUNT_OFF_INVOICE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsVehicleTermType).HasColumnName(@"TRM_IS_VEHICLE_TERM_TYPE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsOptionTermType).HasColumnName(@"TRM_IS_OPTION_TERM_TYPE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsDeliveryTermType).HasColumnName(@"TRM_IS_DELIVERY_TERM_TYPE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsPercentDiscount).HasColumnName(@"TRM_IS_PERCENT_DISCOUNT").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsPriceDiscount).HasColumnName(@"TRM_IS_PRICE_DISCOUNT").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmIsFixedPrice).HasColumnName(@"TRM_IS_FIXED_PRICE").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<string>(x => x.TrmPrimaryRfoNumber).HasColumnName(@"TRM_PRIMARY_RFO_NUMBER").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(40);
modelBuilder.Entity<Term>().Property<string>(x => x.TrmSecondaryRfoNumber).HasColumnName(@"TRM_SECONDARY_RFO_NUMBER").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(40);
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.TrmExcludeOptions).HasColumnName(@"TRM_EXCLUDE_OPTIONS").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.DateTime>(x => x.VqsCreateDate).HasColumnName(@"VQS_CREATE_DATE").HasColumnType(@"datetime").IsRequired().ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<System.DateTime>>(x => x.VqsUpdateDate).HasColumnName(@"VQS_UPDATE_DATE").HasColumnType(@"datetime").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<bool>(x => x.VqsMarkedForDelete).HasColumnName(@"VQS_MARKED_FOR_DELETE").HasColumnType(@"bit").IsRequired().ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<string>(x => x.VqsCreateUserName).HasColumnName(@"VQS_CREATE_USER_NAME").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(50);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsLastUpdatedUserName).HasColumnName(@"VQS_LAST_UPDATED_USER_NAME").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(50);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsCreateSessionId).HasColumnName(@"VQS_CREATE_SESSION_ID").HasColumnType(@"varchar").IsRequired().ValueGeneratedNever().HasMaxLength(128);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsLastUpdatedSessionId).HasColumnName(@"VQS_LAST_UPDATED_SESSION_ID").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(128);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsCreateIpAddress).HasColumnName(@"VQS_CREATE_IP_ADDRESS").HasColumnType(@"varchar").IsRequired().ValueGeneratedNever().HasMaxLength(15);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsLastUpdatedIpAddress).HasColumnName(@"VQS_LAST_UPDATED_IP_ADDRESS").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(15);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsCreateSessionInfo).HasColumnName(@"VQS_CREATE_SESSION_INFO").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(255);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsLastUpdatedSessionInfo).HasColumnName(@"VQS_LAST_UPDATED_SESSION_INFO").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(255);
modelBuilder.Entity<Term>().Property<bool>(x => x.VqsAllowDelete).HasColumnName(@"VQS_ALLOW_DELETE").HasColumnType(@"bit").IsRequired().ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<bool>>(x => x.VqsAllowEdit).HasColumnName(@"VQS_ALLOW_EDIT").HasColumnType(@"bit").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<string>(x => x.VqsRffu1).HasColumnName(@"VQS_RFFU_1").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(50);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsRffu2).HasColumnName(@"VQS_RFFU_2").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(50);
modelBuilder.Entity<Term>().Property<string>(x => x.VqsRffu3).HasColumnName(@"VQS_RFFU_3").HasColumnType(@"varchar").ValueGeneratedNever().HasMaxLength(50);
modelBuilder.Entity<Term>().Property<System.Nullable<System.DateTime>>(x => x.TrmEffectiveFromDate).HasColumnName(@"TRM_EFFECTIVE_FROM_DATE").HasColumnType(@"datetime").ValueGeneratedNever();
modelBuilder.Entity<Term>().Property<System.Nullable<System.DateTime>>(x => x.TrmEffectiveToDate).HasColumnName(@"TRM_EFFECTIVE_TO_DATE").HasColumnType(@"datetime").ValueGeneratedNever();
modelBuilder.Entity<Term>().HasKey(@"TrmId");
}

And here is the table that it was generated from:-

CREATE TABLE [dbo].[TERMS](
[TRM_ID] [int] IDENTITY(1,1) NOT NULL,
[TRM_CLIENT_ID] [int] NULL,
[TRM_VEHICLE_FROM_DATE] [datetime] NULL,
[TRM_VEHICLE_DISCONTINUED_DATE] [datetime] NULL,
[TRM_CAP_MANUFACTURER_ID] [int] NULL,
[TRM_CAP_RANGE_ID] [int] NULL,
[TRM_CAP_MODEL_ID] [int] NULL,
[TRM_CAP_TRIM_ID] [int] NULL,
[TRM_CAP_DERIVATIVE_ID] [int] NULL,
[TRM_CAP_ID] [int] NULL,
[TRM_CAP_CODE] [varchar](40) NULL,
[TRM_VEHICLE_DISPLAY] [varchar](255) NULL,
[TRM_OPTION_CATEGORY_CODE] [int] NULL,
[TRM_OPTION_CODE] [int] NULL,
[TRM_ACTIVE] [bit] NULL,
[TRM_VALUE] [decimal](8, 2) NULL,
[TRM_ADDITION_TO_DEALER_DISCOUNT] [bit] NULL,
[TRM_IN_LIEU_OF_DEALER_DISCOUNT] [bit] NULL,
[TRM_MANUFACTURER_DISCOUNT_ON_INVOICE] [bit] NULL,
[TRM_MANUFACTURER_DISCOUNT_OFF_INVOICE] [bit] NULL,
[TRM_IS_VEHICLE_TERM_TYPE] [bit] NULL,
[TRM_IS_OPTION_TERM_TYPE] [bit] NULL,
[TRM_IS_DELIVERY_TERM_TYPE] [bit] NULL,
[TRM_IS_PERCENT_DISCOUNT] [bit] NULL,
[TRM_IS_PRICE_DISCOUNT] [bit] NULL,
[TRM_IS_FIXED_PRICE] [bit] NULL,
[TRM_PRIMARY_RFO_NUMBER] [varchar](40) NULL,
[TRM_SECONDARY_RFO_NUMBER] [varchar](40) NULL,
[TRM_EXCLUDE_OPTIONS] [bit] NULL,
[VQS_CREATE_DATE] [datetime] NOT NULL,
[VQS_UPDATE_DATE] [datetime] NULL,
[VQS_MARKED_FOR_DELETE] [bit] NOT NULL,
[VQS_CREATE_USER_NAME] [varchar](50) NULL,
[VQS_LAST_UPDATED_USER_NAME] [varchar](50) NULL,
[VQS_CREATE_SESSION_ID] [varchar](128) NOT NULL,
[VQS_LAST_UPDATED_SESSION_ID] [varchar](128) NULL,
[VQS_CREATE_IP_ADDRESS] [varchar](15) NOT NULL,
[VQS_LAST_UPDATED_IP_ADDRESS] [varchar](15) NULL,
[VQS_CREATE_SESSION_INFO] [varchar](255) NULL,
[VQS_LAST_UPDATED_SESSION_INFO] [varchar](255) NULL,
[VQS_ALLOW_DELETE] [bit] NOT NULL,
[VQS_ALLOW_EDIT] [bit] NULL,
[VQS_RFFU_1] [varchar](50) NULL,
[VQS_RFFU_2] [varchar](50) NULL,
[VQS_RFFU_3] [varchar](50) NULL,
[TRM_EFFECTIVE_FROM_DATE] [datetime] NULL,
[TRM_EFFECTIVE_TO_DATE] [datetime] NULL,
CONSTRAINT [PK_TERMS] PRIMARY KEY CLUSTERED
(
[TRM_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


This is the code that I am calling to retrieve the data...

using (var vqsDbContext = new VqsDbContext())
{
var terms = vqsDbContext.Terms.Where(x => !x.VqsMarkedForDelete);
}


Any guidance would be very much appreciated.

Many thanks in advance.

Simon

Shalex
Site Admin
Posts: 8321
Joined: Thu 14 Aug 2008 12:44

Re: NotSupportedException: Data type 'varchar' is not supported in this form

Post by Shalex » Thu 16 Jun 2016 11:00

We have reproduced the issue and identified it. We will notify you when the corresponding build of Entity Developer is available for download.

A workaround is provided by email.

Shalex
Site Admin
Posts: 8321
Joined: Thu 14 Aug 2008 12:44

Re: NotSupportedException: Data type 'varchar' is not supported in this form

Post by Shalex » Thu 07 Jul 2016 17:44

The bug with specifying length of data types in the code generated by the EF Core template is fixed (SQL Server) in the 6.0.40 build of Entity Developer: viewtopic.php?f=32&t=33936.

Post Reply