Tools for scaffolding a .NETCore WebAPI project with Entity Framework and integration tests - entity-framework

I'm making the switch from frontend/Angular to backend/.NETCore. The biggest hurdle I've had is understanding what goes into scaffolding, especially when it comes to integration testing a WebAPI project and Entity Framework migrations.
Are there scaffolding tools similar to Angular Cli that promote good practices around things like setting up new projects or adding new classes in an organized, easily maintainable way?

Currently there is dotnet new which gives you both project templates (dotnet new razor, dotnet new mvc) as well as item templates (dotnet new page).
For entity framework, there is dotnet ef to help creating database contexts for existing databases (dotnet ef dbcontext scaffold) as well as managing migrations (dotnet ef migrations …).

I create new .NET Core projects using Visual Studio 2017 so the IDE automatically sets everything up in organised and maintainable way. It is certainly possible to do this in similar way to Angular CLI with .NET Core CLI. If you're creating .NET Core 2.x project you can find all the required commands here. For example; dotnet new webapi --name MyWebApiProject creates a web api project. To add Entity Framework you can use EF Core .NET Command-line Tools in similar way. Please find all EF Core commands here.

Related

What is the best approach to read from both Web.config and appsettings.json in a .NET Standard library?

We have an old .NET Framework nuget package built with .NET Framework that reads settings from Web.configs files on .NET Framework projects using the ConfigurationManager.AppSettings class. Now, we need to migrate it to .NET Standard to be able to use it on .NET Core projects also.
Is there an elegant way to try to find and read settings from both Web.config files when running in .NET Framework, and from appsetting.json when running on a .NET Core project? Does it make sense?
Also, it makes sense to have 2 different nuget packages, one for use only on .NET Framework projects and another to use only in .NET Core projects?
The main goal is to read setting independent of the .NET version it is running on.

EF6 Entity Data Model Designer not available with target framework .net 5.0

I have an existing .NET Framework-based solution that I'm migrating to .net 5.0. I'm not migrating data access just now: we'll keep using EF6 model-first. After converting projects to .net 5.0 I've tried opening the .edmx file only to get a message:
The Entity Data Model Designer is unable to display the file you requested.
The Entity Framework is not available in the target framework currently specified for the project. You can change the target framework of the project or edit the model in the XML Editor.
The target framework is net5.0.
Should this work?
No, as per EF docs:
There's currently no support for using the EF designer directly on
.NET Core or .NET Standard projects or on an SDK-style .NET Framework
project.
Thanks to #ErikEJ for a detailed walkthrough of a workaround.

Entity Framework Core project with .Net Core and .Net Framework projects

I am creating a bot using Microsoft Bot Framework and the project is using .NET Framework 4.6.1. I am also creating another project for user interface using .NET Core. Since both projects will be using same database so I am thinking to create an another common project using Entity Framework Core. But this project will not be working with .NET Framework 4.6.1.
Could anyone suggest me how to implement this requirement ?

Using EF6 and EF5 Tools side by side in VS2012

I have this situation where I want to start using EF6 for new projects, because EF6 is the latest version, but I still want to be able the work on my old projects that use EF5.
To use EF6 in VS2012, I need to install the Entity Framework 6 Tools, but the problem is that install instructions say that "When you install the RC1 tooling it will replace the EF Designer that was included in Visual Studio 2012"
So to my understating, VS2012 will be unable to work with the old projects that use EF5?
The EF6 desing tools support both EF5 and EF6

MVC 4 Application Using Entity Framework

I recently did a portion of the MVCMusicStore tutorial using MVC3 as directed. However, being that I have Visual Studio 2012, I'm attempting to use EF in an MVC4 application. I was attempting to add the using System.Data.Entity; directive and it was not found.
I know that I can probably just add the reference to it. But I'd like to know why it's not already available for my MVC4 project. Is there a new method of creating an Entity Framework supported application using MVC4?
Entity Framework is now being distributed separately from Visual Studio through the NuGet package management system as of Visual Studio 2012. The reason for this is to decouple EF from the release of VS, so it can be released on a different time schedule. They have also recently released EF as an open source framework, so it's being removed as a project from the .net framework release.
You have to use NuGet to install Entity Framework in your project. Right click on the project and choose Manage Nuget Packages. Make sure you select the Online tab in the dialog that opens, then in the search type Entity Framework and click Install. You will then be able to add the using statement.