Connection must be opened

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Thomas Heinze
Posts: 10
Joined: Fri 18 Jul 2014 16:42

Connection must be opened

Post by Thomas Heinze » Fri 18 Jul 2014 16:58

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.

Thomas Heinze
Posts: 10
Joined: Fri 18 Jul 2014 16:42

Re: Connection must be opened

Post by Thomas Heinze » Fri 18 Jul 2014 20:37

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection must be opened

Post by Shalex » Wed 23 Jul 2014 17:03

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection must be opened

Post by Shalex » Thu 31 Jul 2014 15:07

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.

Post Reply