Page 1 of 1

General EntityDAC issues

Posted: Thu 06 Mar 2014 15:31
by JustinCase
I am in the process of choosing an ORM for use in my company's applications. We use Delphi XE5 atm.
I am trying to set up a basic app with an SQLExpress db. As an experienced .net programmer, who is used to NHibernate, it is frustrating that the documentation is very lacking. It mostly explains how to do this by dropping Components into a form, not how to execute codebehind. Anyway, my specific issue is:

I have 2 classes, Person and Product. Both are autogenerated from Entity Developer.
My setup seems fine, as my database is created:

Code: Select all

      Conn := TEntityConnection.Create(self);
      Conn.ConnectionString := 'Provider=SQLOLEDB.1;Initial Catalog=Test2;Data Source=.\SQLEXPRESS;User ID=sa;Password=xxx;';
      Conn.DefaultModelName := 'TestModel';
      Conn.ProviderName := 'ADO';
      Conn.Dialect := 'SQL Server';
      Conn.Connect;
      Conn.CreateDatabase();
Now, I want to create a New person and insert it to my db. Followed instructions from the documentation:

Code: Select all

Conn := TEntityConnection.Create(self);
      Conn.ConnectionString := 'Provider=SQLOLEDB.1;Initial Catalog=Test2;Data Source=.\SQLEXPRESS;User ID=sa;Password=xxx;';
      Conn.DefaultModelName := 'TestModel';
      Conn.ProviderName := 'ADO';
      Conn.Dialect := 'SQL Server';
      Conn.Connect;
      Context:=TEntityContext.Create(self);
      Context.ModelName:='TestModel';
      Context.Connection:=Conn;
      p:=TPerson.Create;
      p.Name:='Bono Vox';
      p.Email:='[email protected]';
      p.Phone:='12345678';
      Context.Attach(p);
      p.Save;
However this fails at "Context.Attach(p)", with a memory access violation error. Stepped through this line by line; the person Object is created and the Properties filled, but it will not add it to the context. I have tried several approaches:

Code: Select all

p.Attach(Context);

Code: Select all

p:= Context.CreateAttachedEntity(EmpType, 1);
I have also tried setting the primary key (ID) of the person without effect, and anyway the ID is a db generated Identity seed.

Any ideas on where I go wrong here?

Re: General EntityDAC issues

Posted: Fri 07 Mar 2014 10:43
by AlexP
Hello,

Thank you for the information. We have reproduced and fixed the problem. This fix will be included to the next Beta release, that is planned for the next week

Re: General EntityDAC issues

Posted: Fri 07 Mar 2014 14:23
by JustinCase
Oh, it's like that, huh? ;) Glad it's not just me being silly.

Then I may aswell alert you to another problem i found:
When using Entity Developer to create my datamodel, i set some Properties on my "Person" class as such:

Name -> varchar(MAX)
Email -> varchar(255)
... etc.

in my .enml file it comes out like this:

DbType="varchar(255) NOT NULL"
DbType="varchar(MAX) NOT NULL"

However, when I now run my Application to create the db, it always creates varchar(1), meaning only 1 character may be stored in the Field. Tried different approaches to this but the result is always the same. Just so you know... ;)

Anyway, thanks for your swift response.

PS: Using MSSQL Express 2008.

Re: General EntityDAC issues

Posted: Tue 11 Mar 2014 10:31
by AlexP
Thank you. We will consider the possibility to use data entered to the Server Data Type field when generating DDL. Currently, you can specify the field size in Property Editor in the Max Length field (digit only allowed).

Re: General EntityDAC issues

Posted: Sun 16 Mar 2014 16:22
by SDobi
Hi,

I downloaded the latest beta to try out and decide if i need to switch form Aurelius here.

1st problem:
The Entity Developer cannot find the templates for demo application so I cannot create a new model nor edit the demo model.

It is a beta limitation or there is a fix for it?

My question is about a time frame when this product will get out of beta, I need decide which ORM/DataAccess lib to use for my next project which will start in April.

Right now I own Aurelius but I don't like it much. The EntityDAC seems to me more polished product and the Entity Developer boundle is a big plus.

Re: General EntityDAC issues

Posted: Wed 19 Mar 2014 12:51
by AlexP
1) This problem is already fixed and will be included in the next beta version.

We plan to release EntityDAC within a month.