fpdave100 wrote:
Hi
I had/have 'Emit Fk fields' set already.
How do I tell I have got the latest designer? (it states "4.2 Final, July 21st 2015" in titlebar)
The website is often a good start
-> latest build is from September 5th, with designer build from August 2nd.
Looking at the changelogs (http://www.llblgen.com/Pages/ChangelogBrowser.aspx) there aren't any changes in EF templates since July 17th, so you have these.
Some of the issues:
- missing FK (no navigator available to express it)
In CF you need to specify both navigators. Did you remove one of them?
- several missing cascade on delete, eg:
sql generated by llblgen:
ALTER TABLE [dbo].[BILLING_ADraftBillingDocLine]
ADD CONSTRAINT [FK_ADraftBillingDocLineBillingProcessDAO] FOREIGN KEY
(
[ProcessDataId]
)
REFERENCES [dbo].[BILLING_ABillingProcessData]
(
[Id]
)
ON DELETE CASCADE
ON UPDATE NO ACTION
CF code:
protected virtual void MapADraftBillingDocLine(EntityTypeConfiguration<ADraftBillingDocLine> config)
{
config.ToTable("BILLING_ADraftBillingDocLine");
:
config.Property(t => t.ProcessDataId).IsRequired();
:
config.HasRequired(t => t.ProcessData).WithMany(t => t.DocumentLines).HasForeignKey(t => t.ProcessDataId).[b]WillCascadeOnDelete[/b](true);
Isn't that correct? The FK defines delete cascade, so does the relationship? (it's been a long day, I might overlook something)
sql generated from CF:
alter table [dbo].[BILLING_ADraftBillingDocLine] add constraint [ADraftBillingDocLine_ProcessData] foreign key ([ProcessDataId]) references [dbo].[BILLING_ABillingProcessData]([Id]);
That, I can't help with, if EF generates the wrong SQL... Though I can't say the CF code is wrong, so that the ddl sql generated by CF is different... that's something I can't fix for you. (the DDL SQL generated by the designer is actually better, as it's from the DB, not a reverse engineering on reverse engineering)
- timestamps comeout as varbainary
sql generated by llblgen:
[Timestamp] [timestamp] NULL,
sql from CF:
[Timestamp] [varbinary](max) null,
What's the CF code for the field?
**- decimals come out as 18,2 by default, but designer generated them as 18,9 (probably as we specified)
**
Yes, and again, if EF generates SQL from it, it might be the information in the model used for that isn't as precise as the info we have in the designer, e.g. because they reverse engineer from .net types and we don't specify specific db type specifics in the CF code as it's not needed at runtime. (so it has less information)
- Xml data type comes out as nvarchar, eg:
[XmlData] [nvarchar] (max) COLLATE Latin1_General_CI_AS NOT NULL
Same as above.
We don't generate DB type specifics into the CF code as it's not needed for the runtime and the code is generated from the model which has much precise ddl sql output. (we do the same with Nhibernate btw).
This also doesn't tie your CF mappings to a specific DB type, but that aside.
Anyway, the timestamp type is odd as well as the missing cascading delete directive as it's in the CF code, other than that, the DDL SQL generated from CF model is less ideal at the moment as there's not enough information emitted in the code as that information isn't needed at runtime. The schema create/update scripts can be generated from the designer which is more precise and by not generating the type specifics in the CF code, it's less cluttered with info it doesn't need at runtime.
Of course, if the CF code is meant to create the DB at startup, it has a bit of a problem as there's less info than needed available for that in some cases (although it should be able to generate better sql than what you got from it
)
Does that weed out a bit of the problems you have?