Invalid object name 'table_name'

Web app insists in displaying a message Invalid object name ‘AccountsEN’. I do not know about rules I avoided. Only thing I have done was differencing elements by suffix: EN for entity, MI for menu item etc. The reason for this was to have evidence over different types of model elements.

Is this the reason for the message and objects in some relation should have the same name? Or what are rules for naming an element?

I will try my luck in answering your question -

I would bet it’s comming from a database, AccountsEN would be a table name, you forget to run deployment script generator and run the create scripts…

Or I got it - you originally named the table ‘Accounts’ and then you renamed it in architect to ‘AccountsEN’ due to you convenction.

Am I right?

If not, please post the full traceback from log file here…

But renaming isn’t so easy. The database wasn’t changed. So you have to either delete the table and deployment scripts as well and run deployment script generator then. Or you have to create particular very special renaming sql script by hand and put add it into deployment manually.

So you can name your table as you wish - you must not break only sql rules for naming the tables. So it isn’t definitely the reson of the message.

Nevertheless we have some convenctions for entities:
We name them in singular form, so in your case i would name it ‘Account’.If the name consists of more words we use upper-camel-case convenction e.g. InvoiceItem. But there are more of them, maybe would be worth to write them to one place.

1 Like

You are right. I had all names unified originally. Only thing I tried was to run deploment script. When I opened it I was surprised It contains a query only to make a table instead of renaming. It starts making sense.

The script I have created (by Depl. Scr. Gen.) makes a new database table with the desired name beside of the old one. Everything works but in DB there is a unused table. Am I right?

Yes. Deployment script generator isn’t so smart. Renaming the table could result into complicated sql - you can’t simply rename a table if it is e.g. referenced by column from different table.
However, it can show you the differences between a model and a database. When you open the depl. s. gen, try to select ‘missing in model’ or ‘missing in database’.

The message Invalid object name ‘table_name’ actually comes from the SQL Server and indicates that the table is physically missing from the database.

Reasons:

  1. You did not run your initial deployment script
  2. You renamed the table in the entity model but did not create a renaming deployment script (as @urbanekv correctly said it is not currently generated automatically in any way by the Deployment Script Generator utility so you have to do this manually)
  3. Your settings are pointing to a wrong database
  4. Your database permissions do not allow you to see the table