I am using entity framework 6, dotConnect MySql 8.3.313.6.
Sample context:
Code: Select all
public class TestContext : DbContext
{
static TestContext()
{
Database.SetInitializer(
new DropCreateDatabaseAlways<TestContext>());
}
public TestContext():base("name=TestContext")
{
}
public DbSet<TestEntity> TestEntities { get; set; }
}
public abstract class BaseEntity
{
[StringLength(50)]
public string CreatedBy { get; set; }
public DateTime? CreatedOn { get; set; }
[StringLength(50)]
public string ModifyBy { get; set; }
public DateTime? ModifyOn { get; set; }
}
public partial class TestEntity : BaseEntity
{
public TestEntity()
{
}
[Key]
[ScaffoldColumn(false)]
public int TestEntityID { get; set; }
[StringLength(255)]
[Required]
public string Name { get; set; }
[StringLength(50)]
public string DelimiterRegex { get; set; }
}
Code: Select all
using (var ctx = new TestContext())
{
ctx.TestEntities.Add(new TestEntity
{
Name = "12345",
CreatedOn = DateTime.UtcNow,
CreatedBy = "admin",
ModifyOn = DateTime.UtcNow,
ModifyBy = "admin",
});
ctx.SaveChanges();
}
When I am changing column DelimiterRegex to something different, it works without exception.Unhandled Exception: System.Data.Entity.Infrastructure.DbUpdateException: An err
or occurred while updating the entries. See the inner exception for details. ---
> System.Data.Entity.Core.UpdateException: An error occurred while updating the
entries. See the inner exception for details. ---> Devart.Data.MySql.MySqlExcept
ion: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'VALUES ('12345', NUL
L, 'admin', '2014-12-23 15:35:56.302391', 'admin', '2014-12-' at line 1
However, we are porting application from MS SQL to My SQL, and I would prefer not to use different column naming, because this will cause issues during transition period.
When I am doing direct insert to MySQL table, it works without issues:
Code: Select all
insert into TestDB.TestEntities
(Name, DelimiterRegex, CreatedOn, CreatedBy, ModifyOn, ModifyBy )
VALUES ('Test', '123', '2014-12-23 19:29:22', 'admin', '2014-12-23 19:29:22', 'admin');
Sample project here - https://dl.dropboxusercontent.com/u/712 ... SqlBug.zip