简体   繁体   中英

Model classes are not listed when "a controller using Entity Framework" is added

I'm working on ASP.NET MVC test project. I decided to isolate my DataLayer from the main project.

I added another project to my solution. I created all my model classes (public access modifier). Then I created my context class so DbContext can make relationships with my models.

Then, I created my repositories using interfaces and implemented them. I used Entity Framework to do migrations. Finally, I could create my code-first database in SQL Server.

Now, I want to add an admin area to my main project. After adding, I decided to add controllers using Entity Framework. But it doesn't list my DataLayer and its model classes in the list. All the classes I've made have a namespace of "DataLayer". I searched StackOverFlow and found a similar question but the answers did not solve my problem.

How can I fix this?

My solution:

在此处输入图像描述

在此处输入图像描述

I solved it. I referenced the first project in the second project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM