EntityFrameworkCore support for stored procedure - .net-core

I am learning dotnet core and trying my hand on EntityFrameworkCore 2.2.I am trying my lab using database first approach, where I want to execute stored procedures which will contain multiple joins. Stored procedures perform read write operation. I am looking for option which is similar to EF6 in botnet 4.5 framework, where we only import stored procedure from DB and entity framework create complex type for DB result.I read multiple articles but none of these has clearly mention that whether EF core support stored procedure or not ,I want to execute mostly complex stored procedure which contains joins etc.
What I found in multiple tutorial is that everyone is importing tables in EFCore but not only complex SP. Any kind of help and suggestion will be very helpful like how to achieve it or any link to article.

I was facing the same issue and after searching it on internet i have found this resource:
Execute Stored Procedures In MVC Core Using Entity Framework Core
Now I am able to call complex type SP from EFCore, hope it will help you.
Thanks

Related

Entity framework or just SQL queries

I'm doing a project with ASP.net core. I found that most of developers use Entity Framework for dealing with the database. I have worked with raw SQL queries with ASP.NET. I'm using SQL SERVER 2014 and have to develop a RESTfull API to deal with my database. My database consists of about 50 tables.
So my question is, what method is better for my task, using Entity Framework or using raw SQL queries?
From my research I have found that Entity Framework has basically two methods, Code first and Database first. I have looked into both methods. I need to know pros and cons of using entity framework compared to normal SQL queries.
And finally is there a effect on .net core with entity framework?
It seems that you have a large application, my recommendation is that you should use Entity Framework because you have LINQ. (Examples here: http://www.entityframeworktutorial.net/Querying-with-EDM.aspx).
With LINQ you can build your queries using methods instead of strings.
With LINQ:
var L2EQuery = context.Students.where(s => s.StudentName == "Bill");
With Native SQL:
var studentName = ctx.Students
.SqlQuery("Select studentid, studentname, standardId
from Student
where studentname='Bill'")
.FirstOrDefault<Student>();
Using entity framework with code first migrations and a decoupled from ef repository pattern architecture does not restrict you from using sql queries as well sometimes when you need to.
Your question will be closed because it is too opinion oriented.
But yes, personally, I greatly encourage the use of Entity Framework.
The thing is, if you have no experience at all in EF, then you will be subject to a learning curve. Which means it will still be easier for you to simply use SQL query in your code. That said, if you take your time and learn correctly how to use EF it will probably be of good use later.
I've experienced both Entity Framework and raw SQL queries, and now that i'm used to EF, I find it much better.

Create webapp with full stored procedures

I want to create a web application, all actions (Create, Update, Delete) should be done using SQL stored procedure. Every action in the web just calls a stored procedure and receives json data to render the view.
So what is the best framework that I can use? Please help
So what is the best .Net framework that I can use?
Every .Net Framework has ways to retrieve data from database. So, it doesn't really matter what version of .NET Framework you use.
I believe you would like to know what kind of library you should use for Store Procedures. If so, you might want to look at Dapper ORM.
Dapper ORM is created by Stack Exchange, and used in a lot of sites including Stack Overflow.
It basically is a wrapper around ADO.NET to map SQL result to strongly type object. If you have to do the mapping manually, it is very tedious and error prone process. So, I highly recommend using Dapper ORM if you have to call Store Procedures.

Managing Azure SQL database from Azure Mobile App ( SQL-SSMS or EntityFramework)?

I'm new to Azure and started an Azure Mobile App Quick-Start (.NET) project.
I'm studying on this blog wrote by Adrian Hall:
https://shellmonger.com/2016/05/09/30-days-of-zumo-v2-azure-mobile-apps-day-18-asp-net-authentication/. However, I've been confused by the explanation saying that:
Since this is Entity Framework, I would normally need to do an Entity
Framework Code First Migration to get that field onto my database. You
can find several walk-throughs of the process online. This isn’t an
Entity Framework blog, so I’ll leave that process to better minds than
mine. Just know that you have to deal with this aspect when using the
ASP.NET backend.
On the next page, https://shellmonger.com/2016/05/11/30-days-of-zumo-v2-azure-mobile-apps-day-19-asp-net-table-controllers/
The demonstration was using SQL syntax to create/manage the Azure SQL Database, such as: CREATE TABLE... and CREATE TRIGGER... and etc.
So, my question is, with either SQL(like the blog sample shown) or Entity Framework:1) Are they both able to do the exact same stuff?2) Should I only choose one of those methods only?
All the methods discussed (code first, model first, database first) provide you with a way to create a SQL database and update the data within it. The end result is the same - a database with data.
The method you pick tends to rely on where you prefer the 'intelligence' for your data to live - with the database or with the code.
Do you already have an existing database you'll be using?
Go database first, so you can automatically generate code and classes from the database.
Do you know SQL? Do you prefer to use your database for data only (i.e. no stored procedures or validating data inside the database)?
Go code first, you have full control of your model from the Code, and its a bit easier to keep databases in sync with your application.
There are a few more considerations that can help skew you to a different method. You can take a look at this blog post from Roland about the pros and cons of each approach.
There's also a StackOverflow thread that summarizes the differences between the methods.

Is it possible to do model-first ORM mapping with ServiceStack and OrmLite?

I'm just discovering ServiceStack for the first time this weekend and I find it completely amazing. As such, I'm already in the process of converting all of my projects over to it. Then I ran into a small snag.
I can't find any documentation that mentions using OrmLite starting with the database first and then mapping an existing schema into POCOs.
I've found plenty of material on code-first, but nothing on model-first.
Is there a way to use OrmLiite taking a model-first approach?
Thank you.
OrmLite is primarily a code-first ORM, but if you want to start with an existing database you would just create a POCO with properties that maps 1:1 to an existing Table and columns.
It's trivial to infer a POCO manually, but if you want some code-gen tool to help do this, OrmLite includes a couple of T4 scripts you could use instead.

Will using dblinq to SQLite in a Windows Store app pass store validation?

I've been trying to figure out how to get a decent LINQ to something working for ORM database access in a Windows Store app.
All I've found is SQLite and the sqlite-net NuGet package. The latter sucks a bit, as I don't get any .dbml like structure which resolves relationships and provides navigation properties for easy querying (no manual joins needed then).
I was wondering:
Does dblinq in comnbination with SQLite offer this?
Will using this pass Windows Store validation?
Thank you !
Update: Some links I used in my research:
The famous Tim Heuer post on SQLite and Windows 8: http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx
DBlinq: http://code.google.com/p/dblinq2007/
sqlite-net: http://code.google.com/p/sqlite-net/
Interesting discussion stating ADO.NET is not possible: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/e9cdd75d-03e4-4577-988e-4c02a52e3f50
I'm not familiar with dblinq but by looking at the sqlite tests in the project, it seems the library is offering what you're looking for, i.e. navigation properties for relationships between different tables.
Since dblinq is a .NET library, using it shouldn't make the store validation fail. There is another problem though: you can't use such a .NET library in a Windows Store application, only Windows Store class libraries and portable class libraries are allowed. Since the source for the library is available, you can try compiling it as a Windows Store class library, but I'm afraid there are going to be some classes missing that dblinq is depending on which might make it difficult to port.

Resources