I am trying to create a create method which will insert rows into my database.
Table
This is my database table. As you can see it has an accountId column
CREATE TABLE [dbo].[Transactions](
[Id] [int] NOT NULL,
[AccountId] [int] NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Class
This is my transactions class as you can see the class name is transactions the same as the table and there is an account id column.
public class Transactions
{
public int Id { get; set; }
public int AccountId { get; set; }
}
create method
Here is my create method which should insert a row into the database.
public async Task<int> CreateAsync(Transactions transactions)
{
using var dbConnection = await _connectionFactory.CreateConnectionAsync();
return await dbConnection.ExecuteAsync("""
insert into Transactions (AccountId)
VALUES (@AccountId)
""", new { AccountId = transactions.AccountId});
}
I have also tryed to just pass transactions but it didnt work either so i tried. new { AccountId = transactions.AccountId}
Issue
As you can see from this image no matter what i do it wont detect the columns.
What i have tried
I have chosen the correct schema, I have also tried to disconnect the database and reconnect again.
I am at a loss as to why this doesnt work. I have another method which is get and passes and Id that works, I also have another service which connects to another table and i can create an insert statement for that table.