EF6 inserting "\ n" in request?

I recently discovered the beauty of Entity Framework 6 and decided to implement it in my current project. However, I came across a strange problem today. I've searched the internet for many hours but haven't come to any solution yet.

First, some information that might be useful;

  • We are using MariaDB for our database.
  • We are using the MySql provider for EF6.
  • The established connection is local and works. The database is responding correctly to the correct queries in my application.

Problem: For some reason, EF generates a request containing "\ n". Since my error looks like this:

"You have an error in the SQL syntax, check the manual that corresponds to your version of MariaDB server for proper syntax to use near (the SELECT \ n table

. column1

, \ N table

. column2

, \ N table

. column3

Line 1"

I literally copied the query in my database frontend (this is HeidiSql, for those interested) and after removing the "\ n" the query works fine.

The error occurs when:

using(var db = new DataContext())
{
   table tab = new table
   {
      column1 = "Some value",
      column2 = "Some other value",
      column3 = "Yet, another value"
   };
   db.table.Add(tab);
   db.SaveChanges();      //This is where the error occurs
}

      

I have debugged the input and it is correct. Also, the table was correctly added to the table object. The code also compiles as it should.

The weird thing is that this is the only place where the error occurs (for now - I have to check it out more to be sure of this). I call db.SaveChanges()

in other places and somehow no error occurs there. In other words; I can actually add and save data to the database for other more complex tables. It doesn't seem to work.

There are no primary or foreign keys in the table (this is also not needed by anyone, I thought about it.).

Did I miss something?

+3


source to share


1 answer


In EF, you cannot have an entity mapped without a PC definition.



+1


source







All Articles