Wrong dbType on MSSQL create data item

Hello,

I am having trouble with an MSSQL create data item method. The data is of type string/nvarchar, but the insert-command in the log appears to try inserting it as datetime, which is wrong.

From data/DB.json model :

"MdlmExternalUserOrder": {
      "x-table": "dbo.MDLM_ExternalUserOrder",
      "resource": "MdlmExternalUserOrders",
      "required": [
        "FirstName",
        "LastName",
        "JobTitle",
        "InvoiceCompanyID",
        "ExternalCompanyID",
        "LocationID",
        "MobilePhoneNumberPrefix",
        "MobilePhoneNumber",
        "ExternalEmail",
        "StartDate",
        "ServiceUserTypeID",
        "OrderedByUserUPN",
        "OrderDate"
      ],
      "properties": {
...
"MobilePhoneNumberPrefix": {
          "x-nullable": false,
          "type": "string",
          "dbType": "nvarchar",
          "length": 50
        },
...
}

The string in question is "+46" or "+47".
Error on insert, note how parameter @p12 (MobilePhoneNumberPrefix) is DbType=DateTime, when it should have been nvarchar:

dotnet: fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (4ms) [Parameters=[@p0='?' (DbType = Date), @p1='?' (DbType = Int32), @p2='?' (Size = 4000), @p3='?' (Size = 4000), @p4='?' (Size = 4000), @p5='?' (DbType = Int32), @p6='?' (Size = 4000), @p7='?' (Size = 4000), @p8='?' (DbType = Int32), @p9='?' (DbType = Int32), @p10='?' (Size = 4000), @p11='?' (Size = 4000), @p12='?' (DbType = DateTime), @p13='?' (Size = 4000), @p14='?' (DbType = Boolean), @p15='?' (DbType = Boolean), @p16='?' (DbType = Int32), @p17='?' (DbType = Date), @p18='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
      SET NOCOUNT ON;
      INSERT INTO [dbo].[MDLM_ExternalUserOrder] ([EndDate], [ExternalCompanyID], [ExternalCompanyName], [ExternalEmail], [FirstName], [InvoiceCompanyID], [JobTitle], [LastName], [LocationID], [ManagerUserID], [MobilePhoneNumber], [MobilePhoneNumberPrefix], [OrderDate], [OrderedByUserUPN], [ServiceNetwork], [ServicePrint], [ServiceUserTypeID], [StartDate], [UserOrderID])
      VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16, @p17, @p18);
      SELECT [OrderID]
      FROM [dbo].[MDLM_ExternalUserOrder]
      WHERE @@ROWCOUNT = 1 AND [OrderID] = scope_identity();

dotnet: fail: Microsoft.EntityFrameworkCore.Update[10000]
      An exception occurred in the database while saving changes for context type 'Brukeradministrasjonsportal.Data.MdlmIdrettsKontorDbContext'.
      Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
       ---> System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
         at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value)
         at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value)
         at System.Data.SqlTypes.SqlDateTime..ctor(DateTime value)
         at Microsoft.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb)
         at Microsoft.Data.SqlClient.TdsParser.WriteUnterminatedValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj, Int32 paramSize, Boolean isDataFeed)
         at Microsoft.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj, Int32 paramSize, Boolean isDataFeed)
         at Microsoft.Data.SqlClient.TdsParser.TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParameter param, MetaType mt, Byte options)
         at Microsoft.Data.SqlClient.TdsParser.TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam)

Hi @chrtro,

If you have Radzen IDE active subscription please send us your database schema (just schema, no data) to info@radzen.com to try to reproduce and debug your case.

Thank you, email with database schema is sent.

Hi @chrtro,

I was able to scaffold an Blazor server .NET 7 app using Radzen IDE out of your schema however this field is definitely bound to a TextBox not a DatePicker:

Do you get this error only when you enter such strings?

Unfortunately I was not able to test the add since there are lot of interdependencies with required fields.

In my app this property is bound to a dropdown, populated with strings from another database table.

Removing the property from the dropdown and setting it manually to "astring" during page load still produces the same error on insert.

In this case it seems you are using some custom/cusomized CRUD pages in your app for this table. Can you send us an runnable app where we can reproduce and debug the problem?

I have sent you my app, with the unnecessary pages removed.

Press to open the form. Fill the fields with the required datatypes and press save to submit and get the error

Update: The issue was caused by not set DateTime property. After setting the property the error was fixed.