ADO.NET Entity Framework: Update Wizard will not add tables

后端 未结 13 1335
陌清茗
陌清茗 2020-12-13 11:55

I added a new ADO.Net Entity Data Model into my project and used the Update Wizard to add tables into the model. Five of the selected tables were added to the design surfac

相关标签:
13条回答
  • 2020-12-13 12:10

    Check for 'Nulls' in your particular table. If all the columns are set to 'Allow Null' Entity Framework considers it as a 'Null' table. I had the same problem and unchecked 'Allow Null' and it added the required table.

    0 讨论(0)
  • 2020-12-13 12:10

    Tables without primary keys will not be added.

    0 讨论(0)
  • 2020-12-13 12:14

    I had this problem too, all the above didn't work for me. What helped for me was the following.

    When you try to connect with a database that database can have different users with different credentials it can accept. Let's say user A till D.

    If you try to connect with a user make sure that user has the right credentials enabled, in this case, read and write options enabled.

    To do this start MS SQL Server Managment Studio, connected with your SQL server and select the database you try to make a connection with in visual studio. Under 'your_dbname' --> Security --> Users you find a list of users. Rightclick the username you try to login with and select properties. A window opens. Select the 'General' (selected by default) page and under tab 'Database role membership' make sure 'db_datareader' and 'db_datawrite' are selected.

    Note: When you log in too MS SQL Server Managment Studio make sure you log in with a user which can enable/disable these options...

    0 讨论(0)
  • 2020-12-13 12:17

    You do not need to delete the entire model (that might be hundreds of tables!).

    The Wizard can handle "adding new" items, but some changes such as changing composite keys and renaming columns - it doesn't know what to do - so it doesn't try - and things get out of sync.

    SO: DELETE the tables in question from the Model (conceptual mode) AND from the Model.Store, and then Update the model using the Wizard, and re-add just the tables in question.

    0 讨论(0)
  • 2020-12-13 12:23

    One other solution is to ensure the account you are accessing the database via has some permissions to the table, Select at least. The table won't be added if the account has no permissions to it.

    In SSMS under Security, right click the user or role, then Properties. Then click on Securables. The top table shows tables currently accessible. If the missing tables aren't there, click on search and find then, highlight them in the top table, then assign permissions in the lower table

    0 讨论(0)
  • 2020-12-13 12:25

    1.Change the Table structure and add a Primary Column. Update the Model.

    2.Modify the .EDMX file in XML Editor and try adding a New Column under tag for this specific table. (WILL NOT WORK)

    3.Instead of creating a new Primary Column to Exiting table, i will make a composite key by involving all the existing columns.(WORKED)

    Entity Framework: Adding DataTable with no Primary Key to Entity Model.

    0 讨论(0)
提交回复
热议问题