Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: New setup, cannot get past MissingFieldsException #1148

Open
moxplod opened this issue May 14, 2023 · 1 comment
Open

Question: New setup, cannot get past MissingFieldsException #1148

moxplod opened this issue May 14, 2023 · 1 comment
Labels
question Further information is requested

Comments

@moxplod
Copy link

moxplod commented May 14, 2023

Hi, I am new to RepoDB. Trying it with Postgres. I might be doing something obvious that is wrong as I cannot get it to work. I keep getting this error. Please let me know if there is something I need to try or how to debug this.

RepoDb.Exceptions.MissingFieldsException
There are no database fields found for table 'Account'. Make sure that the target table 'Account' is present in the database and/or at least a single field is available.

Here is my setup:

Setup:

static RepoDbRepository()
    {
        GlobalConfiguration
            .Setup()
            .UsePostgreSql();
    }

Trying this test:


[Fact]
        public void AccountInsertTest()
        {
            // Initialize the library for global initialization
            var repoDb = new RepoDbRepository<Account>(false);
            
            using var connection = DatabaseFactory.CreateSqlConnection(false);
            var id = connection.Insert<Account, long>(
                new Account
                {
                    AccountStatus = AccountStatus.Active,
                    AccountType = AccountType.Admin,
                    DateCreated = DateTime.UtcNow,
                    DateUpdated = DateTime.UtcNow
                });
            id.ShouldNotBe(0);
        }


Throws the exception:

image

Here is the table:


CREATE TABLE account( 
	id bigserial PRIMARY KEY,
	type varchar(36) NOT NULL,
	status varchar(36) NOT NULL,
	companyname varchar(128),
	stripecustomerid varchar(36),
	datecreated timestamp NOT NULL,
	dateupdated timestamp NOT NULL);


@moxplod moxplod added the question Further information is requested label May 14, 2023
@Sindrenj
Copy link

Sindrenj commented May 28, 2023

I'm stuck with this too.. I've never been able to use RepoDB with my database. All my tables have snake_casing so I use Map() but still it doesen't work. It also looks like repodbs table-resolver is case-sensitive I've manage to make thisisatable to work while ThisIsATable does not work.. Map("text") is case-sensitive it seems. And if you are lucky that the table is found then the column/properties are not matched if the column name does not match the property in casing. Doesen't make sense when SQL normally is case-insensitive.. But maybe Postgresql is case-sensitive on this.. I don't know..

@moxplod Try setting Map("account") i believe that Repodb is looking for "Account" not "account" in your db because the c# object has its first letter as uppercase..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants