Page 1 of 1

Connection must be opened

Posted: Fri 18 Jul 2014 16:58
by Thomas Heinze
Hi Devart Team,

i am currently trying working Devart dotConnect with EF6 Code First.
The Database creation and adding table is working fine.

But first i have the problem with the seed function. The Data will not entered into table. But if i create a new entry with another method the autoincrement is 2 and not 1.

The next error if i would like insert new data i get the error "Connection must be opened".

I am currently working with dotConnect 6.8.333.

Re: Connection must be opened

Posted: Fri 18 Jul 2014 20:37
by Thomas Heinze
So, i have tested it with the new version 7.3.201 and it works.

Now i have annother Problem with the DataBaseGeneratedOption.Identity.

I have a lot of tables that will have a character varying as primary key but i would have a serial column.

My Model

Code: Select all

[DataBaseGenerated(DataBaseGeneratedOption.Identity)]
public int CustomerID { get; set; } // That should be the serial field

[Key]
[MaxLength(32)]
public string CustomerGuId { get; set; } 
The primary key will be added to the CustomerGuId. But the CustomerID comes as normal integer without autoincreament (serial).

If have tried that with an MSSql and it works fine there.

My first solution is to set the [Key] to CustomerID with [Column(Order=1)] and on CustomerGuId [Column(Order=2)]. That works an the CustomerID is an serial type.

But i have to primary keys.

is there another solution?

Re: Connection must be opened

Posted: Wed 23 Jul 2014 17:03
by Shalex
Thomas Heinze wrote:The primary key will be added to the CustomerGuId. But the CustomerID comes as normal integer without autoincreament (serial).
Your approach assumes that the database table is created by EF code, isn't it? I.e. there is no a predefined table in database.
We have reproduced the problem when int (instead of serial) column is generated for non-EntityKey property with the DatabaseGeneratedOption.Identity attribute. We will notify you when the issue is fixed.

Re: Connection must be opened

Posted: Thu 31 Jul 2014 15:07
by Shalex
New build of dotConnect for PostgreSQL 7.3.215 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with active subscription only).

The bug with applying DatabaseGeneratedOption.Identity for non-EntityKey integer properties in the Code-First/Code-First Migrations functionality is fixed in this version.

For more information, please refer to http://forums.devart.com/viewtopic.php?f=3&t=30076.