Entity not resolved in code first DataService with Entity Framework 4.1?

Well it says "Department" was not found in the entity sets and your entity set name is "Departments" so try pluralizing the call.

Up vote 1 down vote favorite share g+ share fb share tw.

I'm making a DataService with Entity Framework 4.1 using Code First POCO objects. I can access the data fine when I create an instance of MyEntityContext and access it directly, however when I try and access the DataService over HTTP it breaks with the following error: System. ArgumentException: The given name 'Department' was not found in the entity sets.

I've tried all sorts of things but keep coming back to the same problem. Not sure what could be wrong. Department is the only Entity I am mapping currently.

It is defined as follows: Table("tb_department") public class Department { Key Column("department_no", TypeName = "nvarchar") public string ID { get; set; } Column("department_name", TypeName = "nvarchar") public string Name { get; set; } } My data context looks like this: public class MyEntityContext : DbContext { public MyEntityContext(string connStr) : base(connStr) { } public MyEntityContext() { } public DbSet Departments { get; set; } } And my service looks like this: ServiceBehavior(IncludeExceptionDetailInFaults = true) public class MyDataService : DataService { public static void InitializeService(DataServiceConfiguration config) { config. DataServiceBehavior. MaxProtocolVersion = DataServiceProtocolVersion.

V2; config. UseVerboseErrors = true; config. SetEntitySetAccessRule("Department", EntitySetRights.

AllRead); } protected override MyEntityContext CreateDataSource() { MyEntityContext ctx = new MyEntityContext( Utility. GenerateConnStr ); return ctx; } } c# entity-framework-4 ef-code-first link|improve this question asked Jul 22 '11 at 18:18codemonkey1136 78% accept rate.

Now I feel stupid! Thanks that was all I needed :) – codemonkey Jul 22 '11 at 18:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions