How to add EF CLass Library to solution that will work with .net 4.5 and dotnet core - asp.net

I currently have a webforms website using .net 4.5.
I would like to add a class library with entity framewrok.
I want to make sure that this class library works with dotnet core and my existing webforms project.
With all the versions of .net, it is very confusing.
From what I gathered, dotnet standard maybe used as the middle ware for this type a situation. But I'm not sure this is true.
Any suggestions?

Yes, you'll have to use the .NET Standard and Entity Framework Core. .NET Framework will be able to interface with the .NET Standard
I would start up with https://www.youtube.com/watch?v=ECNLyvxLnuQ
There's not a lot of docs on standard, but this will give you some conceptual understanding

Notice that "ASP.NET vs ASP.NET Core" and "Entity Framework vs Entity Framework Core" are completely different frameworks, even though which were named similarly.
ASP.NET and Entity Framework targets .NET Framework which means they can only work on .NET Framework.
ASP.NET Core and Entity Framework Core targets .NET Standard which means they can work on both .NET Framework and .NET Core.
WebForms bases on ASP.NET, and there is no (and not planned) migration for it on ASP.NET Core, so the old WebForms projects will never be able to work on .NET Core.
It is a great quantity of the task migrating from ASP.NET MVC to ASP.NET Core MVC, and WebForms is even impossible.
If you really need to run your project on .NET Core, there will be a complete refactoring of your whole project:
Refactoring your WebForms project to ASP.NET Core MVC (Completely redevelop the whole project)
Refactoring your Entity Framework data definitions to Entity Framework Core (It only supports code-first and database-first, there is no model-first any more)
Make sure that all referenced .NET libraries target .NET Standard or .NET Core and reference them on nuget. If not, re-target an alternative.
If your project is planned to be hosted on Linux server and referenced some native libraries, you have to get the equivalent .so libraries instead of .dll libraries.

Related

which version of mvc is using in asp.net core 2.0? is is MVC 6 or use different name?

which version of mvc is using in asp.net core 2.0? is is MVC 6 or use different name ?
What is .net 5?
what is .net standard ?
these questions are from an interview.plz help
The .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations.https://learn.microsoft.com/en-us/dotnet/standard/net-standard .ASP.NET5.0 Is Called ASP.NET Core 1.0 and In the ASP.NET Core 1.0 release, Web API is merged with ASP.NET MVC, termed as MVC 6
They're totally unrelated. "MVC 6" was sort of like a codename for Core when it was still in early stages. ASP.NET MVC and ASP.NET Web Api are totally separate from ASP.NET Core. Now, it's just "Core". There is no "MVC" or "Web Api", because Core controllers do both functions. ASP.NET MVC and ASP.NET Web Api live on and although they will probably eventually be deprecated, they could presumably (though not likely at all) get new releases. At the very least, they'll be patched for the foreseeable future.
ASP.NET Core is a complete rewrite from the ground up. It was originally created simply to be a cross-platform alternative to ASP.NET, and I think the original plan was to keep both ASP.NET and ASP.NET Core as potential development options. However, as ASP.NET Core became more competent, it has pretty fully eclipsed ASP.NET; we now have a cross-platform framework that can run on Windows, Mac and Linux and can do virtually anything the Windows-only framework can. Therefore, why keep the Windows-only framework?
Asp.net Core 2.0 is MVC 6 and The framework is 4.6.1
To start with development you need to have VS-2017 and for 1.X you can start with VS-2015.
Please refer the below link for clear presentation of .NetCore 2.0 so that you can get good knowledge to kick start your development.
Official Asp.Net Core Documentation Url

.Net Core Assembly issues

I am converting an existing .Net framework 4.6.2 Project into a .Net core project. I have some of the DLLs in the .Net framework 4.6.2, while some DLLs are not supported in .Net core. Below is the list of those DLLs. Can any one give me the solution?
System.ComponentModel.Composition
System.Runtime.Remoting
system.serviceModel
The following is based on a comment I added to the question:
System.Web and System.ComponentModel.Composition are both supported and provided for .NET Core version 2.0, as can be seen here and here.
(as a side note: https://apisof.net/ is a wonderful resource, provided by Microsoft to aid in figuring out which APIs are available in the different .NET platforms).
But System.Runtime.Remoting is not supported by .NET Core at this time.
The listing for System.ServiceModel shows that it is supported in .NET Core, but only when Platform Extensions is included along side it.
If you need access to Windows or .NET Framework specific APIs, then it's recommended that you don't use .NET Core for the project or create a .NET Standard class library/project which includes the .NET Framework specific code and consume the outputs of that.
The following are some resources to help with .NET Core and .NET Framework API specific issues:
https://apisof.net/
Immo Landwerth's videos on what .NET Standard is, and how it relates to the different .NET Platforms (he's the PM for .NET Standard)
A blog post I wrote about .NET Standard and how it fits into the .NET ecosystem
A blog post from codeshare.co.uk describing the key differences between .NET Framework and .NET Core
A blog post from Stackify discussing the differences in .NET Framework and Core API space

.NET Core project add reference to .NET Framework project. Why it's possible?

I have followings projects:
.NET Core 2.0 Web Application
.NET Standard 2.0 Class library &
.NET Framework 4.5 Class Library.
I add reference of .net framework class library to asp.net core web api project. and it seems it works very well.
I am wondering why it's possible to add reference of .NET Framework class library project to ASP.NET Core Web API or MVC?
It's not supposed to allow adding only Standard or Core libraries references to Core projects?
Is this core Web project with .NET Framework class libraries references still cross platform?
UPDATE
According to Phiter comment:
"If you import a .net framework library to your project it'll no longer be cross platform, but you can do it freely if you want to. They allow it because you might want to use .net core and still be on windows."
So if this is a reason, if I want to bind my project to .NET Framework and remain on windows why I use Core Web Project from the first place?
I thought we use core projects for cross platform ability and if not, the .Net framework is not a better option?
UPDATE
mason comment:
"Nothing funny: ASP.NET Core project doesn't have to run on .NET Core. It can also be run on .NET Framework.
Just because it's called 'Core' doesn't mean they're related. They could have called it ASP.NET FancyPants and had it run on .NET Core and .NET Framework and you wouldn't be as confused. Microsoft just sucks at naming things."
UPDATE (November 12, 2018)
A first look at changes coming in ASP.NET Core 3.0 - Fully leveraging .NET Core
As announced on the .NET Blog earlier this month, .NET Framework will get fewer of the newer platform and language features that come to .NET Core moving forward, due to the in-place update nature of .NET Framework and the desire to limit changes there that might break existing applications. To ensure ASP.NET Core can fully leverage the improvements coming to .NET Core moving forward, ASP.NET Core will only run on .NET Core starting from 3.0. Moving forward, you can simply think of ASP.NET Core as being part of .NET Core.
Customers utilizing ASP.NET Core on .NET Framework today can continue to do so in a fully supported fashion using the 2.1 LTS release. Support and servicing for 2.1 will continue until at least August 21, 2021 (3 years after its declaration as an LTS release) in accordance with the .NET Core support policy.
This was just added as part of .NET Standard/Core 2.0. As long as the .NET Framework dll only references things in the .NET Standard, it will use type forwarding to the .NET Core implementations.
I do not know what made Microsoft allow referencing .net framework class library into .net core project but as a programmer, I am happy with this allowance.
You see allowing .net core application to reference .net framework libraries is useful in case you want to start with windows and are planning to go cross platform in the future.
We are in a stage where many useful open source libraries do not fully support .net core till the date of this post, masstransit is an example, so when I am developing a new software I will be using .net core project that depends on such libraries and I will update them later when they support .net core.

Best class library project for ASP.NET Core v1.1?

Well, I know the ASP.NET Core v1.1 is fresh, but I am little playing a with it and I am a bit confused about the right class library project choosing in the solution. So here is a scenario:
I start in the Visual Studio 2017 with ASP.NET Core web application project template and choose sub-branch ASP.NET Core (= not with .NET Framework).
Ok, than I would like to add a class library project, but there are two possibilities:
.NET Core Library
.NET Standard Library
Well, ASP.NET Core v1.0 did not support common class libraries, but it seems v1.1 have no problem with that. So result is, I can reference both types.
So my question - is it ok to reference .NET Standard Library to ASP.NET Core project? Or should I reference .NET Core Library only?
You can use .NET Standard Library with .Net Core 1.0. The Standard library is trying to set a common API for the cross platform .net APIs.
You could use it in your project to get experience with it, but choose what makes sense for your class requirements and timeline.
This site has a good article on .NET Standard Library

Why asp boilerplate says core and uses framework?

http://www.aspnetboilerplate.com/ (APB) is a more or less popular site to get asp.net core mvc patterned project templates. Using it you can select »ASP.NET Core 1.0« template and they create a solution for you.
But digging into their project.json files I see they're requesting framework .NET 4.6.1 and NOT netstandard1.x. As of my understanding this is not .NET Core. It's .NET Framework.
Why is this? What's the »core« part of projects generated with APB?

Resources