SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Missing ``Create(...)`` function

Open Choc13 opened this issue 3 years ago • 3 comments
trafficstars

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

Choc13 avatar Nov 10 '22 18:11 Choc13

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?

Thorium avatar Nov 10 '22 18:11 Thorium

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`)
);

Choc13 avatar Nov 10 '22 21:11 Choc13

  • 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.

Thorium avatar Nov 14 '22 09:11 Thorium