How to use Entity Framework 6 Code First in Class Library Project with MVC 5

asp.net-mvc c# class-library entity-framework-6

Question

I have a Class Library Project(.Net Framework) and Asp.Net MVC 5 project in same solution. Then, I add a reference of Class Library to MVC 5 project.

How do I use Entity Framework in class library and reference to MVC 5 and other projects if I have using same database.

1
0
11/16/2018 11:01:44 AM

Popular Answer

The trick is to have the connection string in the client project, in your case MVC project. Either in a web.config or app.config. In your case, it's web.config file. Then you can safely generate your EntityFramework classes in your class library, and can refer to it from any type of project.

0
11/16/2018 11:03:52 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