Generate EF DB specific code

Posts   
 
    
dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 04-Jan-2017 21:21:58   

In this thread one of the questions was about DB specific code (.HasPrecision) being generated by the code first template.

http://llblgen.com/TinyForum/Messages.aspx?ThreadID=23408&HighLight=1

Did this make it into 5.1? If so where can I find it?

Thanks,

Dave Erwin

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jan-2017 06:46:13   

Hi Erwin,

There is no such property construct built-in. However you could add it to your mapping config in a partial class in your generated code. What is the reason that you want this .HasPrecision generated in your decimal or numeric fields?

David Elizondo | LLBLGen Support Team
dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 05-Jan-2017 14:16:38   

The reason is so the EF code first code could be used to create a database. Specifically to create a database for integration testing.

Frans made this comment on 28-Sept-2015 on the thread that I referenced so I just wondered if it actually happened.

Yes, you can create a derived class from the modeler class and override the mapping methods and make changes in the overrides.

However we discussed this and the use case of CF creating the DB is one which is something we want to support so we'll add the definitions of the table fields to the CF mapping code hopefully this week (in v5 which is in development, and then backport it to v4.2). We'll add a setting to the frameworks settings (which is off by default) to generate the info into the CF code, so that saves you from manually adding code which has to be maintained.

I have added it to a partial class but as he said it's code that has to be maintained. Having it generated would be helpful.

Thanks,

Dave Erwin

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 05-Jan-2017 14:56:56   

It's something we plan to add in the future, but it's currently not implemented. To work around this, export a DDL SQL create script from the designer to create a database. this is less ideal, I know, for integration testing perhaps, but that's what's currently available.

Frans Bouma | Lead developer LLBLGen Pro
dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 05-Jan-2017 16:57:02   

OK, thanks. I just wanted to make sure that I wasn't missing something.

Put me down as interested in the feature. It's not terrible to implement it in a partial class but it would be nice if the information available in the model would carry through to code first.

Thanks,

Dave Erwin

dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 06-Jan-2017 16:17:47   

I think I found the place to change codeFirstModelBuilder.lpt to emit .HasPrecision.

Do you take pull requests somewhere?

Thanks,

Dave Erwin

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Jan-2017 05:27:23   

dle4425 wrote:

I think I found the place to change codeFirstModelBuilder.lpt to emit .HasPrecision.

Good simple_smile

dle4425 wrote:

Do you take pull requests somewhere?

Pull requests, no. Templates changes are made by LLBLGen Team. If you made some change to some template, the best way to use it is to create your own template bindings and override the original one. You can do this in the template bindings viewer: create a new template bindings file, (http://www.llblgen.com/Documentation/5.1/Designer/How%20To/TemplatesAdd.htm) and bind the same templateID to your new template file. Then when generating code, in the code generation configuration dialog, click 'Advanced' and make sure your template bindings file is placed above the shipped versions so your templateid binding overrules the one in the shipped templatebindings. This way you can update the LLBLGen installation without losing your custom changes. More info on http://www.llblgen.com/documentation/5.0/SDK

If you need help with any of these tasks just post here.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 07-Jan-2017 10:26:24   

(for clarity: we don't take contributions from 3rd parties in general for copyright reasons. The templates aren't open source so there's no general 'copyright is with the contributors' system. This sounds vague perhaps but we simply can't do this, no offense to your efforts).

Frans Bouma | Lead developer LLBLGen Pro
dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 07-Jan-2017 16:41:10   

No offense taken. I completely understand. Having fun messing with the templates and appreciate the flexibility that is there.

Thanks,

Dave Erwin

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 09-Jan-2017 10:47:43   

simple_smile If you run into problems regarding the templates, just post in this thread and we'll get you back on track simple_smile

Frans Bouma | Lead developer LLBLGen Pro