Domanda

I am using a Firebird 2.1 database together with VS2010 (.NET 4.0) and am trying to get it to work properly with the entity framework.

The problem is, that when I generate an entity from a database table, the framework detects all columns to be part of the primary key. The table is very simple with two integer columns, one of them being set as primary key.

I even have "#PK_GEN#" set as comment of the primary key column.

In the EF-Editor I cannot modify the primary key property of the store object, and since I will have to deal with nullable columns, that is a problem. I can edit the XML code of the model file, but the changes are non-persistent when updating the model, so that is a show-stopper.

Since I only read about similar problems concerning views not tables, I am obviously doing something wrong, but I can't figure it out.

edit: By the way, I just tested the behavior with VS 2012 and it remains unchanged.

Here's the CREATE script. Since I'm new to Firebird, there might me something wrong here as well, but I really don't think so.

CREATE GENERATOR GEN_TESTTABLE_ID;
CREATE TABLE TESTTABLE (
    TESTTABLE_ID  INTEGER NOT NULL,
    VALUE         INTEGER
);
ALTER TABLE TESTTABLE ADD CONSTRAINT PK_TESTTABLE PRIMARY KEY (TESTTABLE_ID);
COMMENT ON COLUMN TESTTABLE.TESTTABLE_ID IS '#PK_GEN#';

SET TERM ^ ;
CREATE OR ALTER TRIGGER TESTTABLE_BI_GEN_ID FOR TESTTABLE
ACTIVE BEFORE INSERT POSITION 0
AS
begin
  if ((new.testtable_id is null) or (new.testtable_id = 0) ) then
    begin
      new.testtable_id = gen_id(gen_testtable_id, 1);
    end
end
^
SET TERM ; ^
È stato utile?

Soluzione

Problem is, that Firebird 2.1 contains a bug, that results in this. Generate the model using Firebird 2.5 and you'll be fine.

Some references here, here, here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top