The entity type Person is not part of the model for the current context.

Sep 9, 2014 at 6:10 PM
Hello,

When I use this framework with the Adventure Works 2014 database, it gives me this error "The entity type Person is not part of the model for the current context."

Here is a copy of my entity
[Table("Person", Schema = "Person")]
public partial class Person : Entity
{
}
and here is the copy of my service
public interface IPersonService : IService<Person>
{
}

public class PersonService : Service<Person>, IPersonService
{
    private readonly IRepositoryAsync<Person> _repository;

    public PersonService(IRepositoryAsync<Person> repository)
        : base(repository)
    {
        _repository = repository;
    }
}

when I instantiate the service and call this method

this.PersonService.ODataQueryable();

I get the error "The entity type Person is not part of the model for the current context."

Any idea how I can resolve this issue?

I followed the northwind tutorial and it works fine, this is happening when I am creating the same for Adventure works 2014

Your help is greatly appreciated!

Thanks,
D
Sep 12, 2014 at 11:13 PM
Edited Sep 12, 2014 at 11:13 PM
Thinks this has to do with AdventureWorks SQL schemas e.g. HumanResources, Person, Purchasing, etc. You may want to do CodeFirst with the EF Team's PowerTools to make sure the AdventureWorks schema names are be generated and included in your EF mappings correctly.

http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d

This is the preferred tool we use.
Marked as answer by lelong37 on 9/12/2014 at 3:13 PM