Issue with Entity Framework SaveChanges() method generating SQL syntax RRS feed

  • Question

  • Hi, I hope I'm posting in the right forum category!

    I'm using the entity framework data model and and ran into the error stated below when trying to add an object/ save changes to an "Accounts" table in my database. Please let me know what my mistake is! Been looking around the forums but still unsure of the solution (I'm super new to programming)

    I've tested this both on localhost and my amazon ec2 server. Both returned the same error. 


    MySql.Data.MySqlClient.MySqlException: 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 '(SELECT
         `Account`.' at line 1


    public void Register(string Email, string Password, string DisplayName, string DOBdd, string DOBmm, string DOByyyy)


    Account acc = new Account();

    acc.UserID = UserIDGenerator(Email);

    acc.UserName = DisplayName;

    acc.Email = Email;

    acc.Password = Password;

    acc.BirthDate = DateCombinator(DOBdd, DOBmm, DOByyyy);

    using (myEntities dc = conn.GetContext())








    <add name="xxxxxxxxxxEntities" connectionString="metadata=res://*/xxxxxxxxx.csdl|res://*/xxxxxxxxx.ssdl|res://*/xxxxxxxxx.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;;User Id=xxxxxxx;password=xxxxxxx;database=xxxxxxxxxx;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />


     I'm using mySql Connector/Net 6.4.4.

    Please let me know if I need to include more information. Thanks!

    Thursday, December 1, 2011 1:43 PM


  • Hi,

    The code you have provided here looks correct, but the error message states that there is a SELECT that goes wrong (not sure why, but it seems like the SELECT is stripped which may indicate some string buffer problems in the MySql driver). I think that this is a MySql specific error and suggest you try to post it on and see if anyone there can help you.

    Unfortunatly, the Connector for MySql has been quite unstable (at least in conjunction with EF) and it's not always easy to know exactly what it does.


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful" if the post helped you to a solution of your problem.
    Thursday, December 1, 2011 3:58 PM