Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFramework using wrong tablename

My code is giving me an EntityCommandExecutionException when i'm trying getting data from my Bieren Table.

The exception message says that it can't find "dbo.Biers" which is quite obvious because it's called "dbo.Bieren".

I can quite easily fix this by just renaming the table in the database. Altough i don't like fixing my database around my code's errors.

How can i make the entity framework use the correct table instead of changing the name of my table?

Thanks in advance.

like image 300
Wessel T. Avatar asked Jun 18 '11 23:06

Wessel T.


1 Answers

Decorate your entity class with the TableAttribute property, e.g.

[Table("Bieren")]
like image 181
Ryan Kirkman Avatar answered Sep 28 '22 07:09

Ryan Kirkman