locked
Entity framework pluralize causing error, 'invalid object table name RRS feed

  • Question

  • I am making changes to a MVC portal application. Using VS 2017 Professional.  When trying to reference the database tables, their names are pluralized, this is causing the error, "Invalid object on the table name. I have googled this issue, and tried the suggestions that I have found, but this error still persists. I have tried:

    1). going to Tools --> Options--> Database Tools--> O/R Designer and changed Pluralization of names to false

    2). updated the OnModelCreating per suggestions, still this error persists.

    Can someone provide suggestions on resolving this error? 

    Thanks,

    Friday, January 19, 2018 2:38 PM

All replies

  • Hi JTrafton1,

    >>Can someone provide suggestions on resolving this error? 

    Based on your description, I create a simple with pluralized named table, which works well. Based on your error, I would suggest that could check your connection string in web.config, and check if it has the same table name on your database and your model.

    In addition, you could try to write the following fluent API to map related database table name.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
         modelBuilder.Entity<YourModelName>().ToTable("yourtableName")
    }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 22, 2018 1:32 AM