After a long constant struggle, finally figured out how to use EF7 Database first approach using MVC 6. This is how it goes:
App.Impl -> project.json:
"frameworks": {
"net451": { },
"dnx451": { }
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final"
},
Then running the command from cmd:
dnx ef dbcontext scaffold "Server=ip,port;Database=db;User Id=user;Password=pass;" EntityFramework.MicrosoftSqlServer
3 problems I am facing with this. On my Impl project.
I have a folder dedicated to Data. My Data folder should contain all Database related things such as DbContext, DbClasses. However, Scaffold creates these files at the root. How can I specify the folder I want these files created?
At my work place, I could have a database with 50 tables. However, what if I only need access to 2? I don't want to add all 50 tables for my project. How can I specify which tables I want?
On my Database, I could have a table named "Users" because it is a table that contain users. However, scaffold should be creating a class as "User", since it is a single user until it becomes List. How can I specify the name of the table being created?
Thank you all for the help.
-o Dataor--output-dir Dataallows to specify output directory,-t Usersor--table Usersallows to create the class for one table Users. See here