EF 4, how to add partial classes EF 4, how to add partial classes oracle oracle

EF 4, how to add partial classes


To summarise the large comment trail...

Check that the partials are being attached together correctly:

  • Make sure that both class definitions are in the same namespace and assembly.
  • Make sure at least one of them is declared as partial (most generated classes are, including EF generated ones).
  • Check to make sure that the newly created partial can see the previous members, to confirm the partials match up.

Where the client is in a different binary (which was the case here)

  • Make sure the client projects binary/references are up to date (perform a clean build / delete the binary copy / recreate the reference), depending upon your project situation.

For this case, the last check was the most important and solved the problem.


You should make sure that:

public partial class CAR {    private int _sequences;    public int sequences    {        get { return _sequences; }        set { _sequences = value; }    }}

In your generated EF class you are required to:

public partial class CAR {}  
  1. Add partial keyword to the EF generated class.
  2. Make sure they reside in the same namespace.


Create a new class in a separate file in the same assembly (although it doesn't have to be the same assembly) and make sure it has the same namespace.

If they are both in the same assembly and namespace you shouldn't have any issues. You'll know that you've got it right when the new partial you've created can see the properties and methods of the generated EF class in the dropdown at the top of the source code editor.