there is a bug with creating of StoredPocedure parametes in EF Core.
I have this simple SP:
Create PROCEDURE [dbo].[Seek_ContainerBewegTest]
@Identnummer nvarchar(10),
@Identnummer2 varchar(10),
@Identnummer3 char(10),
@Identnummer4 nchar(10),
@identnummer5 ntext
AS
Select @Identnummer
GO
You can see everything has size 10, expect the last parameter.
1) If I create the methods with EntityDeveloper, the nvarchar(10) and nchar(10) prameter are created with size = 20! This is wrong. It should be the same as for varchar/char = 10:
Code: Select all
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = @"dbo.Seek_ContainerBewegTest";
DbParameter IdentnummerParameter = cmd.CreateParameter();
IdentnummerParameter.ParameterName = "Identnummer";
IdentnummerParameter.Direction = ParameterDirection.Input;
IdentnummerParameter.DbType = DbType.String;
IdentnummerParameter.Size = 20;
if (Identnummer != null)
{
IdentnummerParameter.Value = Identnummer;
}
else
{
IdentnummerParameter.Value = DBNull.Value;
}
cmd.Parameters.Add(IdentnummerParameter);
DbParameter Identnummer2Parameter = cmd.CreateParameter();
Identnummer2Parameter.ParameterName = "Identnummer2";
Identnummer2Parameter.Direction = ParameterDirection.Input;
Identnummer2Parameter.DbType = DbType.String;
Identnummer2Parameter.Size = 10;
if (Identnummer2 != null)
{
Identnummer2Parameter.Value = Identnummer2;
}
else
{
Identnummer2Parameter.Value = DBNull.Value;
}
cmd.Parameters.Add(Identnummer2Parameter);
DbParameter Identnummer3Parameter = cmd.CreateParameter();
Identnummer3Parameter.ParameterName = "Identnummer3";
Identnummer3Parameter.Direction = ParameterDirection.Input;
Identnummer3Parameter.DbType = DbType.String;
Identnummer3Parameter.Size = 10;
if (Identnummer3 != null)
{
Identnummer3Parameter.Value = Identnummer3;
}
else
{
Identnummer3Parameter.Value = DBNull.Value;
}
cmd.Parameters.Add(Identnummer3Parameter);
DbParameter Identnummer4Parameter = cmd.CreateParameter();
Identnummer4Parameter.ParameterName = "Identnummer4";
Identnummer4Parameter.Direction = ParameterDirection.Input;
Identnummer4Parameter.DbType = DbType.String;
Identnummer4Parameter.Size = 20;
if (Identnummer4 != null)
{
Identnummer4Parameter.Value = Identnummer4;
}
else
{
Identnummer4Parameter.Value = DBNull.Value;
}
cmd.Parameters.Add(Identnummer4Parameter);
DbParameter identnummer5Parameter = cmd.CreateParameter();
identnummer5Parameter.ParameterName = "identnummer5";
identnummer5Parameter.Direction = ParameterDirection.Input;
identnummer5Parameter.DbType = DbType.String;
identnummer5Parameter.Size = 2147483647;
if (identnummer5 != null)
{
identnummer5Parameter.Value = identnummer5;
}
else
{
identnummer5Parameter.Value = DBNull.Value;
}
cmd.Parameters.Add(identnummer5Parameter);