How to resolve the following MappingException

I get the following exception:

The number of members in the conceptual type "MyModel.Customer" does not match the number of elements on the side of the object 'MyNamespace.Customer. Make sure the number of members is the same.

In the following code:

public CusomserService { // ... public IEnumerable<Customer> GetCustomers() { return new Repository<Customer>().All(); } } public class Repository<T>() where T : EntityObject { // ... public IQueryable<T> All() { return _context.CreateObjectSet<T>().AsQueryable<T>(); /* HERE THE EXCEPTION IS THROWN */ } } 

The generics repository worked fine until I made some changes to my EF model. I allow EF to create a database (via Generate database from Model).

Where to begin?


EDIT: I solved it.

The problem had nothing to do with EF or my model. I renamed the data level project (and its assembly name) from original_name.dll to new_name.dll. I updated the link for the service level project to the data level project, but the old assembly (original_name.dll) was still in the bin directory. Removing the old assembly from the service level bin directory and restoring the solution solved the problem.

+6
c # entity-framework
source share
1 answer

It seems that Class MyModel.Customer 'does not match each other' MyNamespace.Customer '.

Try right-clicking on the edmx file and select Run Custom Tool

or right click on edmx in the solution explorer and open xml and check your latest changes.

+9
source share

All Articles