Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
777 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
In my Blazor server application, I am trying to get the records from RazerReconciliation table as follows. I couldn't figure out why I am getting this error.
public async Task<List<RazerReconciliations>> GetOldReconsAsync()
{
var result = await _oyunPalasContext.RazerReconciliation.ToListAsync();
return result;
}
Here is the model;
public class RazerReconciliations
{
public string? PID { get; set; }
public string? ProductName { get; set; }
public float ProductAmount { get; set; }
public Guid ReferenceNo { get; set; }
public int Quantity { get; set; }
public DateTime TransactionDateTime { get; set; }
public string? Explanation { get; set; }
}
Here is the table:
CREATE TABLE [dbo].[RazerReconciliation](
[PID] [nvarchar](50) NULL,
[ProductName] [nvarchar](200) NULL,
[ProductAmount] [float] NULL,
[ReferenceNo] [uniqueidentifier] NOT NULL,
[Quantity] [int] NOT NULL,
[TransactionDateTime] [datetime] NULL,
[Explanation] [varchar](200) NULL
) ON [PRIMARY]
Here is the Context:
public virtual DbSet<RazerReconciliations> RazerReconciliation { get; set; } = null!;
modelBuilder.Entity<RazerReconciliations>().HasNoKey();
According to https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings, try using float in SQL and double in C#.
By the way, maybe decimal datatypes are more suitable.