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.
c # entity-framework
mmutilva
source share