none
SQL Server CE 3.5 SP2 Beta and EF4 [VS 2010 Beta 2] RRS feed

  • Question

  • I have a SQL CE database which consists of 9 tables. When I try to generate the model, VS says:
    "Unable to generate the model because of the following exception: 'The item with identity 'ActId' already exists in the metadata collection."

    Here are two tables which have ActId:

    CREATE TABLE Act
    (
    	ActId       nvarchar(20),
    	ActDate     datetime NOT NULL,
    	Consumer    nvarchar(300) NOT NULL,
    	Description nvarchar(300) NULL,
    	Kilowatt    real NOT NULL,
    	FundFull    real NOT NULL,
    	ActInfoId   int NOT NULL,
    	CONSTRAINT PK_ActId PRIMARY KEY (ActId),
    	CONSTRAINT PK_FK_ActInfoId FOREIGN KEY (ActInfoId) REFERENCES ActInfo (ActInfoId)
    );
    
    CREATE TABLE ActRow
    (
        ActId             nvarchar(20),
        WorkerTableNumber int,
        FundWorker        real NOT NULL,
        CONSTRAINT PK_ActId PRIMARY KEY (ActId, WorkerTableNumber),
        CONSTRAINT PK_FK_ActId FOREIGN KEY (ActId) REFERENCES Act (ActId)
                                                   ON DELETE CASCADE
                                                   ON UPDATE CASCADE,
        CONSTRAINT PK_FK_WorkerTableNumber FOREIGN KEY (WorkerTableNumber)
                                           REFERENCES Worker (WorkerTableNumber)
                                           ON DELETE CASCADE
                                           ON UPDATE CASCADE
    );

    How to fix problem? Thanks beforehand!


    There is no knowledge that is not power.
    Thursday, February 18, 2010 11:26 AM

Answers

All replies

  • Have you tried with VS 2010 RC?

    Have you tested renaming on of the ActId fields?
    http://erikej.blogspot.com Erik Ejlskov Jensen - Please mark as answer, if this was it.
    Monday, February 22, 2010 12:30 PM
    Moderator
  • I renamed columns - and all went fine! :)


    There is no knowledge that is not power.
    Saturday, February 27, 2010 9:33 AM
  • A bug ? - have you tested with VS 2008 SP1?
    http://erikej.blogspot.com Erik Ejlskov Jensen - Please mark as answer, if this was it.
    Sunday, February 28, 2010 11:22 AM
    Moderator
  • As I guess, the problem was that two tables had the same name of constraint - PK_ActId. I just renamed one of them - and all went fine. :)
    There is no knowledge that is not power.
    Monday, March 1, 2010 5:42 AM

  • I've got the same problem, Wonderful answer, The reason is quite out of my expectation.
    Monday, December 20, 2010 1:16 AM