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

Missing Create(...) function #773

Open
Choc13 opened this issue Nov 10, 2022 · 3 comments
Open

Missing Create(...) function #773

Choc13 opened this issue Nov 10, 2022 · 3 comments

Comments

@Choc13
Copy link
Contributor

Choc13 commented Nov 10, 2022

After reading the docs I wanted to use the Create(...) style function as recommended, to ensure that if the columns in the DB change my code will fail to compile due to a mismatch between the required columns in the DB and the values passed to the function. However, I am only able to find the parameterless Create() function in intellisense for all of the tables in the DB. I've also tried crafting the function name manually based on examples and compiling the code, but that fails to compile, so it appears that the type provider has not provided these functions.

Am I missing a setting in the type provider somewhere? I've checked the documentation but couldn't find anything.

Expected behavior
I expected to find that the Create(...) function had been generated.

Desktop:

  • OS: Mac OS X

Additional context

  • SQLProvider: 1.3.1
  • DB Vendor: MySql
  • MySql.Data: 8.0.30
  • .NET: 6.0
@Thorium
Copy link
Member

Thorium commented Nov 10, 2022

Shouldn't be anything special. Your table has to have non-nullable fields. What IDE you are using? VS Code, or VS for Mac or something else?

@Choc13
Copy link
Contributor Author

Choc13 commented Nov 10, 2022

It's VS Code. Here's the table definition for reference.

CREATE TABLE `foo` (
  `id` int NOT NULL AUTO_INCREMENT
  `name` varchar(50) NOT NULL,
  `description` varchar(50) NOT NULL,
  `type` enum('A', 'B') NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
);

Another table definition that also doesn't have the function generated is defined as

CREATE TABLE `bar` (
    `id` int NOT NULL AUTO_INCREMENT,
    `name` varchar(45) NOT NULL,
    `description` varchar(45) NOT NULL,
    `type` varchar(2) NOT NULL,
    `sector_id` int NOT NULL,
    `external_id` int DEFAULT NULL,
    PRIMARY KEY(`id`),
    KEY `sector_id` (`sector_id`),
    CONSTRAINT `bar_sectors_fk` FOREIGN KEY (`sector_id`) REFERENCES `sectors` (`id`)
);

@Thorium
Copy link
Member

Thorium commented Nov 14, 2022

  • Are other tables working better?
  • Are the columns themselves visible in these problematic tables?
  • If not, is there "Error"-property?

I'm just think because maybe there is some exception in design time with intellisense. I've sometimes debugged VS by attaching another instance of VS to another VS, but I have no idea if you can debug VS Code.

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

No branches or pull requests

2 participants