asp.net-mvcvisual-studioentity-frameworkedmxedmx-designer

The number of members in the conceptual type does not match - yet it does


I've suddenly started getting the following error in a .NET 4 MVC project.

The number of members in the conceptual type 'OrnaviModel.Task' does not match with the number of members on the object side type 'Ornavi.Core.Objects.Task'. Make sure the number of members are the same.

The project uses an EDMX file, which is used to generate the required data objects. The project was working fine last week, however now I get this error whenever I add a new field to any entity. Removing the new property immediately fixes the error.

The field has also been added to the underlying database table too, so there shouldn't be a mismatch.

Why has my file suddenly stopped generating correctly? I've tried "Run Custom Tool", to no avail. I've tried on a separate PC, no joy. If I open the EDMX file in XML mode, I can see the new property is there, likewise if I browse to the generated class, the property is there.

Please help.. it's driving me crazy!

EDIT: I've still not got an answer to this, so I'm going to post some screenshots to see if it helps:

I've modified the Tasks table, as follows:

enter image description here

I then click "Generate Database From Model" to refresh the underlying objects. If I expand the DataModel.edmx file, and browse to the relevant class, I can see the new field:

enter image description here

I've added the column to the database too, yet every time I access the page:

The number of members in the conceptual type 'OrnaviModel.Task' does not match with the number of members on the object side type 'Ornavi.Core.Objects.Task'. Make sure the number of members are the same.

Why has this started happening?

I've tried the following: - Run custom tools on the edmx - Make the changes on a different computer - Tried different tables, columns, variable types

Nothing has changed on the laptop - same version of visual studio, no updates have been installed.

Every time, the same issue. If I delete the column, click "Generate Database From Model", it then works fine. Add it back in, same problem.

Please help! The database structure is massive on this project, so I really don't fancy having to recreate the whole thing!

enter image description here


Solution

  • It could be that you have two versions of the model in different projects like the resolution mentioned in this comment from a similar issue:

    Number of members in conceptual type does not match with number of members on object side type