Can't find ADO.net Entity Data Model template in VS2017

前端 未结 21 3276
我寻月下人不归
我寻月下人不归 2020-11-30 06:16

I was trying to create an ASP.NET MVC web application in Visual Studio 2017. I need to take an EF database-first approach for the work.

Unfortunately I can\'t find t

21条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 06:58

    It is true that this feature is not available in Core and this might not answer the question directly. But Core offers Reverse Engineering command line that I have used successfully for project with existing database.

    What you need to do is just run the following command with in your Package Manager Console and it will Generate models for you based on the existing database:

    Scaffold-DbContext 'Data Source=.\SQLEXPRESS;Initial Catalog=DbName;Integrated Security=True;MultipleActiveResultSets=True' Microsoft.EntityFrameworkCore.SqlServer
    

    Or directly from command line using dot net.

    dotnet ef dbcontext scaffold "Data Source=.\SQLEXPRESS;Initial Catalog=DbName;Integrated Security=True;MultipleActiveResultSets=True" Microsoft.EntityFrameworkCore.SqlServer
    

    To learn more about this feature you can read more at Microsoft page:
    https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding

提交回复
热议问题