Mizanur Rahaman
Mizanur Rahaman

Reputation: 453

How to create database first approach exact class project

I just doing a simple CRUD operation using database first approach. I have an ASP.NET MVC project and another a class library project.

I already mentioned ManageEmployee.Management is a class library project, and ManageEmployee.Web is the ASP.NET MVC web project.

Scaffold-DbContext -Connection "Server=MCH-DESKTOP\SQLEXPRESS; Database=AutoSoftSystems; Trusted_Connection=True; MultipleActiveResultSets=true;" 
                   -Provider Microsoft.EntityFrameworkCore.SqlServer 
                   -OutputDir "Models" 
                   -ContextDir "Data" -Context "EmployeeDbContext"

Running this command on the Package Manager console works fine, but the file is generated in the web project.

I want to change path direction. How can I change my path to the ManageEmployee.Management folder?

Upvotes: 0

Views: 449

Answers (3)

Mizanur Rahaman
Mizanur Rahaman

Reputation: 453

Finally I can solved my problem, I just change defaut Project name

enter image description here

Upvotes: 0

csandun
csandun

Reputation: 444

I am highly recommended to use EfCorePowertool visual studio plugin. It is more helpful for me to reverse engineer my existing database through a GUI.

Using that tool you can put the path ../ManageEmployee.Management/Models like the below screenshot.

enter image description here

Upvotes: 1

J.Memisevic
J.Memisevic

Reputation: 1454

Your Default project in Package Manager console is ManageEmployee.Web, you should change that to ManageEmployee.Management and your EmoloyeeDBContext need to be in ManageEmployee.Management also - then you run command to generate models.

Btw I'm pretty sure that if you say that your -OutputDir "../ManageEmployee.Management/Models" that should work also. I have never tried this last part but I think that is worth a try.

Upvotes: 2

Related Questions