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 tried to just pass transactions but it didn't work either so I tried. new { AccountId = transactions.AccountId}
Issue
As you can see from this image no matter what I do it won't 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 doesn't 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.

Choose Schemato select the database/schema to use for validation. Don't expect miracles though. If you connect to multiple databases Rider can't know which one should be used each time. Even then, you may get an error because Rider only knows about DbCommand and parameters. It doesn't know how micro-ORMs like Dapper convert properties to parameterstransactions.transactions.AccountId.@AccountIdparameter, because it doesn't know where it came from. Dapper works fine withnew { AccountId = transactions.AccountId}ornew { transactions.AccountId}. In both cases a new anonymous type with anAccountIdproperty is created, and Dapper maps this to the@AccountIdparameter.