I'm new to Core 2 and am trying to connect to a SQL server to query some info.
I cant get EFCore to scaffold the database because it's an old DB with badly designed links, the scaffold kicks it out and won't work.
I can't alter the tables, it's read only. how can i get this to work, or, can i access the db in a different way? I cant find anything on google that doesn't use efcore.
Thanks,
There are a couple of solutions to achieve this. Since ASP.NET Core 2.0 implements .NET Standard 2.0, you can use ADO.NET with ASP.NET Core. So you can write stored procedure or query to get your data with dataset or datareader.
There are also other lightweight ORM tools like Dapper or NPoco. Both these ORMs allow developers to write SQL queries. Please refer to below posts to find out how to use them with ASP.NET Core
Use Dapper ORM With ASP.NET Core
Use NPoco ORM With ASP.NET Core
Related
Does anybody know whether there is a way to use default OpenIddict storage functionality in a project which doesn't use Entity Framework and has not empty DB?
I'm trying to integrate Openiddict server to my Web App. The app has a DB, but communication with it is done using classic ADO.Net. I tried to find a similar example in the openiddict-samples repository but unfortunately without result.
I know that I can implement my own TokenStore, ApplicationStore etc. and register them via extensions for OpenIddictCoreBuilder but I'd like to use the default implementations in case it's possible to do that with not empty DB and without EF or with EF but for Openiddict functionality only. My DB is quite big and it's not an easy task to migrate it to EF.
I tried to use code from existing examples but those didn't work in my case. What I found out is that it works with empty DB only, otherwise OpenIddict tables are not created.
So I would very appreciate for any advice or link to example which I should investigate more carefully. So to say make OpenIddict to create its tables automatically, under the hood.
P.S.: I of course can copy those tables from examples and include scripts for their creation in my app, but I'd like to use the built-in functionality as much as possible.
OpenIddict version: 3.1.1
It seems that for now there is no a built-in functionality to achieve the wanted behavior. The only way is to create own Stores and StoreResolvers for OpenIddict and migrate tables creation to any suitable solution: a set of sql scripts, some kind of migration (e.g. FluentMigration), etc.
For now OpenIddict out of the box supports EF and Mongo only. This implementations can be considered as examples for implementation of Stores and StoreResolvers.
We are developing a razor application with VueJS on the frontend and razor / ASP.NET Core 5 on the backend. VueJS accesses the data via post (ajax) requests which we are handling using page handlers in the page models.
I have integrated Entity Framework and done a few queries for practice however I am realizing Entity Framework is not my answer. All of my SQL queries are saved as table valued functions in SQL Server and the update / insert / delete operations are done using stored procedures in SQL Server.
We have a SQL programmer so he just does everything server-side to keep things simple and just gives us function / procedure names and parameters.
I like this approach and we used this in our application when it was VBA in Excel using ADO and recordsets but now that we are using ASP.NET Core in a web setting so I am learning Entity Framework. However EF requires me to maintain models and that seems unnecessarily complicated as my SQL results are generated from procedures / functions.
Really I just need to run these procedures / functions and return the results as a json data array in the POST request.
What would be the best option for this in regards to performance and simplicity (hopefully they can go hand in hand)? A simple code example would also be helpful to get the ball rolling.
As for other questions on StackOverflow I have seen one question which is similar that says dapper is great for stored procedures but does not indicate if table valued functions are allowable.
Please note that Entity Framework Core also allows us to execute raw SQL query to make use of existing stored procedure. For more information about executing raw SQL queries with Entity Framework Core, you can check this doc:
https://learn.microsoft.com/en-us/ef/core/querying/raw-sql
Besides, if you want to implement it with ADO.NET approach, you can try to use Microsoft.Data.SqlClient that provides the data provider for Microsoft SQL Server.
https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/
I have an oracle data source that i would like to expose using odata.
The reason i need to use odata is that there are many parameters and it is hard to write a query for each combination.
How can i connect my oracle database to odata to achieve this given that the database is version 10.2g which as i have read does not support Entity framework.
Thanks
One of the solutions is using NHibernate, and here is a sample: http://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/OData/v4/NHibernateQueryableSample/.
I am implementing Membership and security in my MVC4 website using custom database. Every things working fine but when I used .EDMX(Designer) to add my database tables membership and security starts giving errors. I also know the reason: This is due to duplicate Class files as default membership use code first approach and I am using database first approach. My question is there is any soluton that I can work using database first(EDMX) and also my security and membership functionality works fine.
Thanks.
The following post details the steps to take when using SimpleMembership with a Database-First approach: Using MVC 4 SimpleMembership with an existing database-first EF model
Also, you may find the following link has some useful information about SimpleMembership: http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx
I'm looking into WCF and woud like to created my framework in a RESTful way. I've just started looking into ADO.NET Data Services, but it seems it only supports SQL Server, is this correct? Can you run in against Oracle?
ADO.net Data Services and WCF both feed off a model. You can provide restful access to your data using a proper model layer that accommodates Oracle driver. Things might not work out of the box. In WCF you can use an Oracle friendly mapper like NHibernate and expose your datacontracts in a restful way. For Astoria you might need to hunt for a EF provider for Oracle db. But its possible.
EDIT: It seems ADO.net Entity Framework is already Oracle friendly ! You have no problems going pure WCF or Astoria way
Please see the following question for a more up-to-date and thorough answer.
Is it possible to expose data from Oracle using OData?
ADO.NET Data Services relies on the ADO.NET Entity Framework, and that definitely also supports Oracle. WCF in itself is totally database-agnostic - no limitations here. I don't see why you shouldn't be able to use ADO.NET Data Services with an Oracle backend.
Marc
Here's a link on how to do so -
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/EntityFrameworkWCF/WCFEntityFramework.htm
You'll actually need to install ODAC for EF, which is currently in beta:
http://www.oracle.com/technetwork/topics/dotnet/downloads/oracleefbeta-302521.html
It works fine for me in VS, but not in IIS, which is the issue I'm facing.
HTH