Unable to refer in namespace the class library in it ado.net entity data model .edmx in asp.net web application webapi

64 Views Asked by At

I have a classLibrary Project(. Net Framework 4.6.1) namely 'EmployeeDataAccess', it contains an ADO.Net Entity Data Model (.edmx) configured successfully to my SQL-server. I have a separate ASP.Net Web API Project namely 'WebAPI'. Have added reference of the 'EmployeeDataAccess' class library in 'WebAPI' Project. Finally created a controller namely 'EmployeeController.cs' & in namespace when 'using EmployeeDataAccess', the type or namespace could not be found. I have even added reference to EntityFramework, System.Data.Entity, System.Data.Entity.Design in 'WebAPI' Project Reference but still the controller is unable to recognize the 'EmployeeDataAccess' namespace?

Screenshot_of_asked_question

1

There are 1 best solutions below

0
Atul Kumar On

After much research, finally, this is what worked for me:- 1. Added reference to the "latest version of EntityFramework to both class library and main project" to which reference of the class library was to be added. 2. The "Property window of the class library" showed the assembly name and namespace name different from the class library name. Renamed "assembly & namespace name that matched the class library name". 3. Finally, the "using directive in the controller class" of the main project was able to identify the "class library reference" added to the main project.