I'm following the Simple Insert Operation example at https://github.com/tmsmith/Dapper-Extensions#simple-insert-operation
public class Org
{
public int Id { get; set; }
public string Name { get; set; }
}
SqlConnection conn = new SqlConnection("...");
conn.Open();
Org org = new Org() { Name = "Just Testing" };
int id = conn.Insert(org);
conn.Close();
This gives me a System.Data.SqlClient.SqlException: Invalid object name 'Org'.
What am I doing wrong here? The table exists and was generated by EF Code First with the standard DbContext
subclass containing a public DbSet<Org> Orgs { get; set; }
The docs state that "POCO names should match the table name in the database. Pluralized table names are supported through the PlurizedAutoClassMapper."
I just didn't read the docs closely enough, my mistake
In POCO object you can use Table Attribute.
[Table("TableNameInSqlDatabase")]
public class Org
{
public int Id { get; set; }
public string Name { get; set; }
}