All Questions

Tagged with
Filter by
Sorted by
Tagged with
38 votes
4 answers
99k views

How to connect to SQL Server from .NET Core without using Entity Framework?

How can we connect to SQL Server from .NET Core without using Entity Framework?
Charles Okwuagwu's user avatar
24 votes
3 answers
31k views

Transactionscope throwing exception this platform does not support distributed transactions while opening connection object

TransactionScope is throwing a exception in .net core 2.2 In this example I created a scope of TransactioScop. Opening SQL transaction for one database which is working fine. After the first ...
Sushant's user avatar
  • 375
23 votes
7 answers
6k views

Building SQL Server Database Project In Ubuntu

I'm building an ASP.NET Core 2.0 Web API application that is hosted in an Ubuntu environment. So far, I've had great success getting things building and running (for the .NET Core app) in Ubuntu. For ...
Brandon Avant's user avatar
19 votes
3 answers
14k views

Is Microsoft SQL Server Express available for production in Linux?

I'm trying to publish my ASP.NET Core app to Linux for production. My question is, is Microsoft SQL Server Express available for production in Linux? Or do I have to use the paid version?
Boy Pasmo's user avatar
  • 8,221
17 votes
3 answers
11k views

How to do a LIKE in Entity Framework CORE (not full .net)

In the Full .Net EF LIKE's used to be SqlMethods.Like, eg: from c in dc.Organization where SqlMethods.Like(c.Boss, "%Jeremy%") This doesn't work in EF Core and I get this error: The name ...
Jeremy Thompson's user avatar
17 votes
2 answers
1k views

Can't connect to SQL 2008 database using .NET Core 2.0

UPDATE I could never make this work with a "Windows Authentication" (domain) user. But with a "SQL Server Authentication" user everything is working like it's supposed to. ORIGINAL QUESTION My ...
ttt's user avatar
  • 6,480
16 votes
4 answers
12k views

SQL Server Always Encrypted with .NET Core not compatible

I'm trying to use the Always Encrypted feature of SQL Server 2016 with .NET Core and seems like it can not be used (yet). Trying to import the Microsoft.SqlServer.Management.AlwaysEncrypted....
Los Morales's user avatar
  • 2,111
15 votes
1 answer
2k views

Timeout connecting to MSSQL Server 2017 when application running on Linux

I recently started up an ASP.NET Core Web-Application (WebAPI) using Entity Framework Core for database communications and everything was running really smooth as long as I was running the application ...
Fredrik Ek's user avatar
12 votes
1 answer
20k views

Is EnableRetryOnFailure() valid way for solving database deadlocks? Does it have negative influence on performance?

So i encountered problem with deadlocks, i was getting this exception: System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling ...
kkamil4sz's user avatar
  • 481
11 votes
3 answers
20k views

How do I solve SqlNullValueException?

I'm trying to find an entity but I get a SqlNullValueException when entity framework is trying to get the value of a field that's Null. I checked in the database and all the not nullable fields are ...
Friso's user avatar
  • 2,388
11 votes
3 answers
7k views

How to restore a SQL Server backup in .NET Core

I want to restore a SQL Server database (.bak) using .NET Core. Here is my empty website on GitHub so you can see the current config. Restoring a database is fairly simple in the full .NET Framework -...
JsAndDotNet's user avatar
  • 16.6k
11 votes
3 answers
5k views

The SQL Server instance returned an invalid or unsupported protocol version during login negotiation

I am using dotnetcore 1.1 and trying to connect to SQL server version 8.00.2055. I have 2 connections inside project: one to SqlServer 2016 and another one to Sql Server 8.00.2055 (Sql Server 2000?) ...
gandra404's user avatar
  • 5,911
10 votes
2 answers
43k views

EF Core Database First HasNoKey

I have a database table created 20 years ago in my company, it is only used for journaling, with NO PRIMARY KEY or INDEX. I can't alter that table. I understood that we need to call HasNoKey() in ...
s k's user avatar
  • 4,770
10 votes
2 answers
12k views

Distributed Transactions: .NET Framework vs .NET Core

I have the following code sample: static void Main(string[] args) { TransactionManager.DistributedTransactionStarted += (sender, eventArgs) => { Console.WriteLine("Promoted to ...
chrisv's user avatar
  • 563
10 votes
3 answers
21k views

Entity Framework Core - error: keyword not supported: '"server'

I am using Entity Framework Core 2.1. I scaffold my entity classes aka database first. When I try to get the data from one of the db tables, I get an error "keyword not supported for 'server'." I ...
user1250264's user avatar
10 votes
2 answers
6k views

one-to-many relation using two columns in Entity Framework Core

In my project I have a table Translation that can have translations for any model. To achieve this, the table has two fields: Model and ModelId. The Model property holds an integer indicating the type ...
Jerodev's user avatar
  • 32.8k
10 votes
1 answer
2k views

Applying EF Core migrations per tenant schema

I'm working with .NET Core 3.1 and EntityFramework Core 3.1.3. I'm trying to implement tenant data separation using DB schemas. I've read this. I'm aware it's a little bit outdated, so I've adjusted. ...
Michał Górnicki's user avatar
9 votes
3 answers
19k views

Scaffold-DbContext: command not found

i try to reverse engnieer my models from an existing database, but the command: Scaffold-DbContext "Server=(db);Database=xxxx;Trusted_connection=true;" Microsoft.EntityFrameWorkCore.SqlServer -...
eldios1981's user avatar
9 votes
1 answer
6k views

Failed executing DbCommand because timeout expired .net core

My goal is to provide simple API to retrieve data from Payments (~400 rows) table which consists 5 columns. Payment: Id (int), PaymentsNumber (tinyint), Rate (decimal(18,2)), ProductType (tinyint), ...
Shahar Shokrani's user avatar
9 votes
0 answers
604 views

How to fix: 'After MS SQL Server restart alipne .net core 2.2.5 container which use it has one CLOSE_WAIT tcp connection - CPU of dotnet rise'

I have problem with App that is hosted on official asp-dotnet-core-alipne container and SQL Server on other server. After restart server on which we have SQL, containers gets high CPU and some ...
Szymon Szczepanski's user avatar
8 votes
2 answers
10k views

web api in Docker can't connect to SQL Server on host with pre-login handshake error

Firstly there are a few similar questions but I have tried all the suggestions I can find and nothing seems to work. If you can find one I haven't mentioned, please comment and I'll try it out. The ...
thinkOfaNumber's user avatar
8 votes
2 answers
2k views

EF Core Update-Database command creates schema for user instead of using dbo

I have created a DbContext using EF Core 2.0 and already applied a lot of migrations in the development environment using Update-Database in PM-Console. The tables are created using the dboschema on ...
Lightbringer's user avatar
8 votes
2 answers
2k views

AspNetUserLogins table and maximum size of index keys in SQL Server

The schema of the identity model in VS2017/aspnetcore defines a table called AspNetUserLogins table to store external logins (CREATE statement below). It defines the primary key as a composite of [...
user avatar
8 votes
0 answers
4k views

View to Table Relationship in EF Core 3.1

Using SQL Server with Entity Framework Core 3.1. I have a view that I need to join to a table. This obviously works fine within SQL Server. But I can't get the relationship correctly defined in EF. ...
Lloyd's user avatar
  • 111
7 votes
3 answers
3k views

EntityFramework is very slow to compare strings because create a nvarchar sqlparameter instead of varchar

I have this sample query: context.BarcodeTipiDoc.AsQueryable().Where(d => d.Barcode.CompareTo(minBarcode) > 0); That query runs very slow because Entity Framework creates SqlParameter for "...
Stefano Balzarotti's user avatar
7 votes
1 answer
1k views

Does it make sense to wrap the SQL Server Serilog sink inside Async?

I am trying to minimize the performance impact of writing logs to SQL Server from a .NET Core application. In the past I've wrapped a Serilog File sink inside of an Async sink - and that greatly ...
AngryHacker's user avatar
  • 60.5k
7 votes
2 answers
14k views

Best way to update JSON property with EF core

I considering to store some information as a JSON object in a SQL Server database but it is not clear for me how I should update a single property of that object in JSON column but not the whole ...
Stanislav's user avatar
  • 133
7 votes
1 answer
1k views

Use Same Syntax for MongoDB and SQL with C# or Linq

Noticed MongoDB has different keywords, like InsertOne, ReplaceOne , etc. A point of Linq (Language Integrated Query), was to have a universal language where people can utilize dependency injection ...
user avatar
7 votes
4 answers
4k views

.NET Core API can't connect to database via docker-compose

I'm developing a .NET core web API with a MSSQL Server database. I tried to containerize this into a Docker container and use Docker Compose to spin up this service. But my API cannot connect to the ...
Pim's user avatar
  • 113
7 votes
0 answers
403 views

AWS Fargate, .NET Core app with SQL Server fails to connect to failover partner following database failover

We are experiencing an issue with a simple .NET Core (3.1) console app connected to a SQL Server database and deployed in a container on AWS Fargate (ECS). SQL Server is a mirrored setup (principal/...
daithimurf's user avatar
6 votes
1 answer
14k views

C# SqlConnection could not be found

I am trying to connect to the SQL database in my network using the code below. I've searched on Stackoverflow and web for this error and found so many other people experiencing this issue, applied and ...
Peace's user avatar
  • 191
6 votes
3 answers
4k views

There is no metadata information for provider 'SqlServer-20'

I want to test the SQL database features of Quartz.NET 3.0 for .NET Core. Unfortunately, I'm unable to configure the StdSchedulerFactory properly, I always get the following exception when calling ...
feO2x's user avatar
  • 5,558
6 votes
2 answers
3k views

Write a search query which is case insensitive in EF Core?

I want to ask a question about SQL Server and EF Core. Collation in the database is Latin1_CI_AS and I want to write a search query that contains Turkish characters. In the database, there is a ...
Samet Öz's user avatar
6 votes
2 answers
7k views

EF Core force refresh Entity from Database (force fetching values from DB)

I would like to how to load/fetch the current database values for an entity ("force reload from database") with Entity Framework Core. My property looks like the following: [Column(TypeName = "...
Edub's user avatar
  • 518
5 votes
2 answers
4k views

dotnet ef scaffold login fails for user sa on a SqlServer MacOS/Linux

I'm executing this command, and definitely using the correct password, but yet it keeps telling me that the login failed. My password is using a special character ($), and I've read that I should be ...
Elertan's user avatar
  • 377
5 votes
2 answers
3k views

EF Core delete one-to-one relation on same table

A model have optional relation to itself public class Item { public Guid Id { get; set; } public string Description { get; set; } public Guid StockId { get; set; } // optionally ...
Basin's user avatar
  • 977
5 votes
2 answers
8k views

Specifying the column type when using entity framework core 3.1 with SQL Server

Consider this simple class, that I will use for one of my Domain objects with EF Core 3.1: using System; namespace Blah.Domain { public class Response { public int Id { get; set; } ...
Neo's user avatar
  • 3,349
5 votes
2 answers
5k views

EF Core Navigation Property Include uses Left Join instead of Inner Join

In my API project, I have public class Team { [Key] public long Id { set; get; } [Required] public TeamSettings TeamSettings { get; set; } } public class TeamSettings { [Key] ...
Zion Hai's user avatar
  • 360
5 votes
4 answers
2k views

Migration not working

I have a project that uses .net core 2.0 with EntityFrameworkCore, Docker and SQL Server. I can't get migrations to work. When I try Add-Migration InitialCreate I get the following error: Startup ...
Thypari's user avatar
  • 801
5 votes
1 answer
4k views

.net core and ef core sql server error provider: SQL Network Interfaces, error: 8 - Protocol not supported

I've been trying to develop a new application using .net core in MacOsX using a SQL Server database, but i'm having some problems with the connection because i'm getting the following error: fail: ...
Leobardo Mora Castro's user avatar
5 votes
1 answer
14k views

Execute Oracle stored procedure in Entity Framework Core

When I tried to execute an Oracle stored procedure with Entity Framework Core, I get this exception : No mapping to a relational type can be found for the CLR type 'OracleParameter[] I tried ...
Wael Mourad's user avatar
5 votes
3 answers
3k views

.NET Core - Migration Fluent API HasColumnType

I'm using .NET CORE 2.2 and EF CORE for SQLSERVER and PostgreSQL. In postgresql doesn't exists varchar(max) or varchar(-1) like on SQLSERVER,in postgresql the data type is TEXT. On this column, I ...
Paulo Alexandre's user avatar
5 votes
1 answer
4k views

.NET 6 Serilog is not creating log table

I am trying to implement logging using serilog in one of my demo app (using .net 6). I am logging to sql database. I have kept "autoCreateSqlTable" to "true" in appSettings.json ...
Glenn singh's user avatar
5 votes
1 answer
1k views

EF Core 2.0 - System.NotSupportedException On Add [duplicate]

I am using EF Core 2.0. I have a table with 4 columns where the PK is made up of all 4 columns. One of the columns (IsDefault) is a bit field in the database. If I insert a record with IsDefault ...
jkruer01's user avatar
  • 2,195
5 votes
0 answers
201 views

Why temp tables are being created automatically in database

I am using Entity Framework Core 2.1 with .NET Core 2.0. I am using code first approach. I am seeing sometime temp tables are getting created in the database. Here is the screenshot of the problem. ...
Jatinder Singh's user avatar
5 votes
1 answer
2k views

IDistributedCache Removing keys

I've recently started using the sql version of IDistributedCache on a dotnet core web api. How would you remove/invalidate a set of keys for say a specific user? I.e: I structured the keys to follow ...
Pieter's user avatar
  • 4,801
5 votes
0 answers
288 views

DotnetCore app running within Docker on Amazon Linux multidocker container returns an error during Sql Server login process

I have a DotnetCore application (DotNetCore v1.1) running on Docker within an Amazon Linux instance (64bit Amazon Linux 2016.09 v2.5.2 running Multi-container Docker 1.12.6 (Generic)). When I try to ...
AppsInOz's user avatar
5 votes
1 answer
3k views

How to use a SQL output parameter with FromSqlInterpolated? Or alternative

Using ASP.Net core 3.0. my Database query works - I can get the result set (records), but how to pass/get the output parameter? Also would like to know if there's a way to get the return value. I ...
user2026318's user avatar
4 votes
3 answers
7k views

Deploy database using .dacpac file from .Net Core 2.0 application

I'm trying to migrate my app from net 4.6.1 to netcore2.0 and some problems with Microsoft.SqlServer.Dac have been occurred. I'm deploying the database from a .dacpac file using DacServices (...
Oleg Bezhan's user avatar
4 votes
2 answers
9k views

.Net Core Linux Container Won't Connect to SQL Server Using SQL Authentication

A .Net Core 2.2 application running in a Linux Docker container fails to authenticate to SQL Server on a different machine using SQL Authentication. The error message is: Cannot authenticate using ...
no1's user avatar
  • 321

1
2 3 4 5
14