Migrating Web Api to .Net core - entity-framework

I have a .Net FW 4.6 web API project that I would like to upgrade to .Net core.
Currently the project is using ADO library to call stored procedures in the SQL database.
I see that in .Net Core everyone is using Entity framework. Do I have to use it if I want to just call stored procedures?

Related

How to combine CosmosDB, Entity Framework and OData in .Net Core 6.0?

I have an application that uses Entity Framework, OData and SqlServer in a .Net core 3.1 scenario and it works great. Ultimately I want to use Cosmos DB on Azure in lieu of SQL Server.
While I can get the app to connect to Cosmos the application fails in calls to FromSqlRaw which the 3.1 compatible libraries do not support.
I've tried upgrading the project entirely to .Net core 6.0 and while this compiles without error I get problems loading assemblies using a package called MediatR (for injection) when the application starts.
My question is twofold: Do the .Net 6.0 compatible libraries for Cosmos DB correctly handle FromSqlRaw and/or is there a workaround for the problem if they do not.
If you are asking if you can send T-SQL or ANSI-SQL to FromRawSQL in EF with the Cosmos DB provider the answer is no.
Cosmos DB is a NoSQL database. The FromRawSQL is intended to allow users to send Cosmos DB's own dialect of SQL and was put in as a way to make the Cosmos provider higher compatible where the provider maybe lacked specific capabilities exposed by Cosmos DB itself.

linq to sql upgrade path?

I have a .Net Framework library project containing a bunch of models and business logic based off Linq 2 Sql. I currently have a .Net Framework website consuming it. I want to create a new .Net Core Web API and access this library.
What do I upgrade this library to that will allow it to be consumed by both .Net Framework and .Net core? Is there a ".Net Standard Entity Framework?" I can only see .Net Core EF. So I am at a loss as to how to share this logic layer with my old .net framework and new .net core website.
EF 6.3 runs on .net standard and compatible with Framework and Core.

Use EF6 with ASP.NET Core

I am working a new project - and I want to do it using the latest .NET Core.
Reading through the documentation, I came across the comparison between Entity Framework Core and Entity Framework 6.x Comparison. Here
Some of the features that I require like: Spatial Data Type is NOT supported by EF Core. So I CAN'T use it, because Spatial Data Type is required in the Project.
Going through the documentation again, I came across this link on How to use EF 6.x with .NET Core: Here
In the article it mentions (Here):
Before you start, make sure that you compile against full .NET
Framework in your project.json as Entity Framework 6 does not support
.NET Core. If you need cross platform features you will need to
upgrade to Entity Framework Core.
I don't really need my project to be cross platform.
The article is not very clear on how to use EF6 with ASP.NET Core.
I created a new ASP.NET Core Web Application
then I installed EF6 using Nuget Package Manager, and got the following error
I went and removed the netcoreapp1.0 from the frameworks in project.json and added net46 as framework, which removed the error for EF, but now I am getting another error.
So how do I use EF6 with ASP.NET core?
When I use EF6 I have to remove all references to .NET Core, does
this mean I am not using .NET Core? What are the disadvantages of this other than it can't run cross platform?
To stop the second error you need to remove the following from the dependencies section of your project.json:
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
}
For reference, the documentation for referencing the full .NET Framework and Entity Framework 6 from an ASP.NET Core project has a full project.json example.
Removing references to .NET Core does not mean you are not using ASP.NET Core. You are only changing the target runtime platform that your ASP.NET Core project will execute on.
Using ASP.NET Core with the full .NET Framework, you get the benefits of the new project structure and unified story for building web UI and web APIs (e.g. unified Controller class), and you also gain access to the mature, fully-featured .NET Framework, enable use of dependencies and NuGet packages which haven't been ported to .NET Core, for example Entity Framework 6.

Shared library for asp.net core app and windows service

I have an ASP.NET Core web app and a Windows Service that both access the same database. I am using Entity Framework Core as an ORM. I would like to be able to create a library package that encapsulates all data access (ie. a Repository) and can be shared by both the web app and the service.
Entity Framework Core appears to only be supported in DNX applications, and Windows Services, as standard Windows applications, cannot reference DNX projects. Is there any way of creating a DNX Windows Service, or another approach that would work?
Creating a standard windows class library with EF 6.x is not an option as the Repository has already been written in EF Core.
Just discovered my mistake, Entity Framework Core is supported in standard windows projects, so it looks like I have my solution: create a Repository class library that accesses the database using EF Core and reference it from both the ASP.NET Core and Windows Service apps.

Is there anyway making ADO.NET work on .NET Core?

I need ODP.NET (Oracle Data Providers for .NET) on .NET Core but can't find anyway to make it work.
When I reference OracleConnection or OracleCommand classes, the project needs System.Data assembly which I can't find in .NET Core.
So isn't there any solution to use ADO.NET on .NET Core?
The System.Data.Common contract is available for providers to start implementing against. So far, the only implementations on .NET Core that I know of are System.Data.SqlClient and Microsoft.Data.Sqlite.