Is there a first Entity Framework 7 POCO database generator?

I play with Entity Framework 7 and ASP.NET 5 for a new project that I am working on, but I hit the road block. The team I'm working on uses the first DBA development approach; those. The database is designed by the database administrator, and then the developers modify the code to compensate for model changes.

Using EF6, this works well, as we can simply update the code using the EDMX update functionality. One click, we get new classes, and you're done. However, in EF7 everything is different. There is no longer a designer there, and we should use Code-First, which, according to some blog posts posted by the EF team, should also support the generation of Database-First code.

However, I cannot figure out how to do this using Visual Studio 2015 CTP6 in an ASP.NET 5 application. Is there toolkit support there, or am I out of luck? And will it even come at all?

+50
c # sql-server asp.net-core entity-framework-core
Mar 27 '15 at 12:33
source share
3 answers

In the last bits, you can use the dnx command line and powershell commands for this, yes

Scaffold-DbContext '<connectionString>' EntityFramework.MicrosoftSqlServer 

or

 dnx ef dbcontext scaffold "<connectionString>" EntityFramework.MicrosoftSqlServer 

or (from EF Core RC2)

 dotnet ef dbcontext scaffold "<connectionString>" Microsoft.EntityFrameworkCore.SqlServer 

You must install the packages EntityFramework.Commands and EntityFramework.MicrosoftSqlServer.Design for the Work command

+51
Mar 27 '15 at 13:04
source share

This can be done using the NuGet Package Manager console or the command line. I tried with the command line. After navigating to the project folder on the command line, I used a similar command:

 dnx ef dbcontext scaffold "Data Source=myServerName; Initial Catalog=myDatabaseName; Integrated Security=True" EntityFramework.SqlServer 

I am having errors regarding missing packages:

EntityFramework.Commands

EntityFramework.SqlServer.Design

and then run the following command:

 dnu restore 

The actual package needed may vary depending on the specified structure (s) in the project.json file.

If you cannot execute dnx or other related commands on the command line, follow the ETU link which was mentioned in the comments of another answer.

PS . Here is the current list of commands [at the time of writing, last update on August 21]:

ASP.NET - EntityFramework Wiki - NuGet / DNX Commands

+12
Oct 28 '15 at 16:52
source share

Here are the updated parameters for RC2.NET Core (May 2016)

 dotnet ef dbcontext scaffold -c RRStoreContext -o Model "Data Source=(local);Initial Catalog=DBNAME;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer --force 

Note that Microsoft.EntityFrameworkCore.SqlServer is the new package name that should be used in the command. I added a force parameter to overwrite existing files. The "o" parameter displays the directory name. And now dotnet instead of dnx .

In the current release, the dependencies you need in project.json are

 "dependencies": { "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.Tools": { "type": "build", "version": "1.0.0-preview1-final" } }, 

Note. The type 'build' means that everything that refers to your assembly will not perceive this DLL as a dependency, since it is needed only for snap-in.

+8
May 25 '16 at 8:07
source share



All Articles