All Questions
Tagged with entity-framework-core sql-server
1,711
questions
1
vote
2
answers
73
views
Transform DateTime field to provided format in where clause
I'm trying to integrate a search function in my datatable in Asp.Net Core. I load the content dynamically with a query to my MSSQL server. As the database table content will increase drastically over ...
2
votes
1
answer
39
views
Entity property is set prior to SaveChangesAsync then sometimes is saved to the database as null, and changed to null in the entity
I have an intermittent problem. I have a C# API project that reads an entity from the database, updates its properties, then calls DbContext.SaveChangesAsync. The entity has a nullable int ...
0
votes
1
answer
53
views
Many-to-many relationship update in EF Core
In my two classes I created a many-to-many relationship:
public class Author
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[DisplayName(&...
0
votes
1
answer
55
views
Issue with LINQ Query in Async Method: 'The LINQ expression could not be translated'
I have an asynchronous method in C# that retrieves a list of users with various nested includes and filters. The method works fine when I don't pass the arbsResponse parameter, but I encounter an ...
0
votes
2
answers
64
views
Moving database contexts to library project results in "FileNotFound" exception
I have a .NET Core 7 solution EIT which had only 1 project: EIT. This project uses Entity Framework Core to model and access the database. This worked fine.
Now I want to add several Windows services ...
0
votes
0
answers
71
views
Entity Framework Core Unidirectional many-to-many not working
I want to use a Unidirectional many-to-many relationship but I can't seem to get it to work.
I use EF Core 8.0.6 and recreated the example (https://learn.microsoft.com/en-us/ef/core/modeling/...
2
votes
2
answers
182
views
What's the best way to update ~500 entities with EF Core? [closed]
Right now I loop through each entity and call ExecuteUpdateAsync then after the loop I call CommitAsync, but I'd like to know if there is a better way for updating ~500 records?
I see this bulk ...
0
votes
1
answer
47
views
In Entity Framework how should I limit string length to no greater than 12000 characters
I tried the obvious...
[StringLength(12000)]
public string Instructions { get; set; }
...(also tried MaxLength) but when I run add-migration I get empty Up() and Down() methods. The only impact of ...
0
votes
1
answer
47
views
System.Data.SqlClient.SqlException but table is exists in the database [duplicate]
I use Quartz to perform background tasks in my .NET core project. Here is the code for my Quartz:
public class ReportsChangesJob : IJob
{
private readonly IReportsService _reportsService;
...
1
vote
2
answers
62
views
Why do I get the SpecialityName as null here?
I am working with ASP.NET Core And Entity Framework, and when I request this controller I get this.
The problem in using the FromSql method is that it returns the SpecialityName as null, when the same ...
1
vote
1
answer
96
views
How to properly manage and dispose SqlConnection with SqlCredential in EF Core using Dependency Injection?
I am working on an ASP.NET Core project where I am using SqlCredential for database authentication, provided by a SqlCredentialProvider which is designed as a singleton to ensure a single instance ...
0
votes
0
answers
29
views
Why are the relationships in the table not working properly? [duplicate]
There is a database in the project and I want my user to be able to create code sections and they are saved in the database, also the user can like other people's code, and these liked CodeSnippets ...
0
votes
0
answers
59
views
_dbContext.Add query error: Invalid column name
I have two model classes that relate many-to-one to each other:
public class AlertRule: Identity
{
public long RuleId { get; set; }
[ForeignKey(nameof(RuleId))]
public virtual SepRuleBase ...
0
votes
1
answer
54
views
How to transform "Types" a List<string> foo class property into a SQL Server table [Types](FooID int, name nvarchar) with Entity Framework Core
I received a JSON from a REST API, deserialized into a list of foo objects:
class Foo
{
public int Id { get; set; }
public string Name { get; set; }
...
public List<string> Types ...
0
votes
1
answer
87
views
What is the maximum supported compatibility level for EF6?
I'm in the process of migrating old .NET Framework & EF 6 Web API to .NET 8 and EF Core 8.
Yesterday because of this breaking change, I changed compatibility_level to 130 for our Azure SQL ...