I'm getting the following exception:
The number of members in the conceptual type 'MyModel.Customer' does not match with the number of members on the object side type 'MyNamespace.Customer'. Make sure the number of members are 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 was working fine until I made some changes in my EF Model. I'm letting EF create the database (through Generate database from Model option).
Where do I start?
EDIT: I've solved it.
The problem had nothing to do with EF or my model. I had renamed the data layer project (and it's assembly name) from original_name.dll to new_name.dll. I had updated the service layer project reference to the data layer project, but the the old assembly (original_name.dll) was still in the bin directory. Deleting the old assembly from the service layer's bin directory and rebuilding the solution solved the problem.
It seems that Classes 'MyModel.Customer' does not match with each other 'MyNamespace.Customer'.
Try right clicking on the edmx file and selecting Run Custom Tool
or right click on edmx in solution explorer and open with xml and verify your recent changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With