On insert, DapperExtensions returns "Invalid object name."

c# dapper dapper-extensions entity-framework sql-server

Question

At https://github.com/tmsmith/Dapper-Extensions#simple-insert-operation, I'm doing the Simple Insert Operation example.

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();

Thus, I have aSystem.Data.SqlClient.SqlException: Invalid object name 'Org'.

Why am I doing this wrong? The table is real and was produced by EF Code First using the acceptedDbContext subclass that includes apublic DbSet<Org> Orgs { get; set; }

1
3
10/9/2014 9:00:25 PM

Accepted Answer

Documents indicate that "The table names in the database should correspond to the POCO names. The PlurizedAutoClassMapper supports pluralized table names."

My error was that I didn't read the documents carefully enough.

0
11/4/2018 11:08:24 AM

Popular Answer

You may utilize Table Attribute in POCO objects.

[Table("TableNameInSqlDatabase")]
public class Org
{
   public int Id { get; set; }
   public string Name { get; set; }
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow