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

前端 未结 21 3072
我寻月下人不归
我寻月下人不归 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:52

    My solution was to copy an "edmx" file from another project to the project with asp.net core, and works perfect, with all the funtions, the problem is only in the templates availables in the list.

    0 讨论(0)
  • 2020-11-30 06:52

    in my case ,I had used ADO .NET before so I knew it was installed ..so I just typed ADO in the search box on the upper right corner , and THERE it was , SOLVED ! hope this helps

    0 讨论(0)
  • 2020-11-30 06:58

    For those of you trying the other solutions and still not seeing the templates...

    Perhaps you are attempting to add ADO EF to a .NET Core 2.0 project, and EF is not supported out of the box.

    You have 2 options:

    1. Install Core 2.0 SDK and NuGet that is aware of .NET Standard 2.0
    2. Use a .NET 4.x project rather than Core

    I recommend #1. VS 2017 doesn't actually have the full Core 2.0 SDK installed, nor is it available from the VS installer (which many comments here struggle with).

    I know, confusing, right?

    From Microsoft:

    "You will need to download and install a version of the .NET Core 2.0 SDK that is appropriate to your platform. This is true even if you have installed Visual Studio 2017 version 15.3."

    "In order to use EF Core 2.0 or any other .NET Standard 2.0 library with a .NET platforms besides .NET Core 2.0 (e.g. with .NET Framework 4.6.1 or greater) you will need a version of NuGet that is aware of the .NET Standard 2.0 and its compatible frameworks"

    https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-entity-framework-core-2-0/

    Now... got all that installed and still not seeing the ADO template? I believe that is because it is deprecated/obsolete. This is the way to get EF working in .NET Core: https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

    Hope this helps! You're welcome.

    0 讨论(0)
  • 2020-11-30 06:58

    I had to create a new project using .Net 4.5.2 then I was able to add the ADO.NET Entity Data Model.

    1. File -> New Project
    2. Select Web -> ASP.NET Web Application (.NET Framework)
    3. Set Framework at bottom of window to .NET Framework 4.5.2
    4. Use Empty Template
    5. Right click project (not your solution) -> Add -> New Item
    6. Select Data -> ADO.NET Entity Data Model
    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-11-30 07:00

    Not a solution as such, but check that the project you've added is for .NET Framework and not .NET Standard. The templates for adding things such as ADO.NET Entity Data Model are included for .NET Framework.

    0 讨论(0)
提交回复
热议问题