How do you address the following problems? MappingException

c# entity-framework

Question

The following exception is occurring for me:

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 code after:

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 */
    }
}

Up until I made certain modifications to my EF Model, the generics repository was functioning well. I'll let EF build the database (through create a database using the model option).

How do I begin?


EDIT: I figured it out.

The issue was unrelated to EF or my model. I had changed the assembly name of the data layer project from original name.dll to new name.dll. The previous assembly (original name.dll) was still there in the bin directory despite the fact that I had changed the service layer project's reference to the data layer project. The issue was resolved by deleting the outdated assembly from the service layer's bin directory and recreating the solution.

1
6
3/30/2011 1:31:56 PM

Popular Answer

It seems that the classes "MyModel.Customer" and "MyNamespace.Customer" are incompatible.

Try picking Run Custom Tool from the context menu when you right-click the edmx file.

alternatively use the open with XML option when you right-click on the edmx file in Solution Explorer to check your most recent modifications.

9
3/30/2011 12:56:43 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow