Page 1 of 1

VB.NET Template problem with navigation properties (code first)

Posted: Wed 03 Feb 2016 14:25
by scheurich
Hi,

we're facing 2 problems with the code generation template in Entity Developer 5.8.782:

There are 2 tables (Address and Addresstype) Addresstype has a navigation property (Addresses) which points to the Address table. We're using configuration classes with fluent mapping.
The template generates the following config:

Address:

Code: Select all

'------------------------------------------------------------------------------
' This is auto-generated code. 
'------------------------------------------------------------------------------
' This code was generated by Devart Entity Developer tool using Entity Framework DbContext template.
' Code is generated on: 03.02.2016 13:19:49
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
'------------------------------------------------------------------------------

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.Specialized
Imports System.Runtime.Serialization
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Data.Entity.ModelConfiguration

Namespace Model.Mapping

    Public Partial Class AddressConfiguration 
        Inherits EntityTypeConfiguration(Of Address)

        Public Sub New()
            Me _
                .HasKey(Function(p) New With { p.IdAddress }) _
                .ToTable("address", "sentis_luv")
            ' Properties:
            Me _
                .Property(Function(p) p.IdAddress) _
                    .HasColumnName("idAddress") _
                    .IsRequired() _
                    .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity) _
                    .HasColumnType("bigint")
            Me _
                .Property(Function(p) p.IdAddressType) _
                    .HasColumnName("idAddressType") _
                    .IsRequired() _
                    .HasColumnType("bigint")
            Me _
                .Property(Function(p) p.Title) _
                    .HasColumnName("title") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.FirstName) _
                    .HasColumnName("firstName") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.FirstName2) _
                    .HasColumnName("firstName2") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.LastName) _
                    .HasColumnName("lastName") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.NameAddition) _
                    .HasColumnName("nameAddition") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.SaveAs) _
                    .HasColumnName("saveAs") _
                    .HasMaxLength(255) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Position) _
                    .HasColumnName("position") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Company) _
                    .HasColumnName("company") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.PhoneCompany) _
                    .HasColumnName("phoneCompany") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.PhoneMobile) _
                    .HasColumnName("phoneMobile") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.PhonePrivate) _
                    .HasColumnName("phonePrivate") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Mail1) _
                    .HasColumnName("mail1") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Mail2) _
                    .HasColumnName("mail2") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Mail3) _
                    .HasColumnName("mail3") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Fax1) _
                    .HasColumnName("fax1") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Fax2) _
                    .HasColumnName("fax2") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Homepage) _
                    .HasColumnName("homepage") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Street) _
                    .HasColumnName("street") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Zip) _
                    .HasColumnName("zip") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.City) _
                    .HasColumnName("city") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Country) _
                    .HasColumnName("country") _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            Me _
                .Property(Function(p) p.Picture) _
                    .HasColumnName("picture") _
                    .HasColumnType("mediumblob")
            Me _
                .Property(Function(p) p.Comment) _
                    .HasColumnName("comment") _
                    .HasMaxLength(255) _
                    .HasColumnType("varchar")
            OnCreated()
        End Sub

        Partial Private Sub OnCreated()
        End Sub

    End Class
End Namespace

AddressType:

Code: Select all

'------------------------------------------------------------------------------
' This is auto-generated code. 
'------------------------------------------------------------------------------
' This code was generated by Devart Entity Developer tool using Entity Framework DbContext template.
' Code is generated on: 03.02.2016 13:19:49
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
'------------------------------------------------------------------------------

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.Specialized
Imports System.Runtime.Serialization
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Data.Entity.ModelConfiguration

Namespace Model.Mapping

    Public Partial Class AddresstypeConfiguration 
        Inherits EntityTypeConfiguration(Of Addresstype)

        Public Sub New()
            Me _
                .HasKey(Function(p) New With { p.IdaddressType }) _
                .ToTable("addresstype", "sentis_luv")
            ' Properties:
            Me _
                .Property(Function(p) p.IdaddressType) _
                    .HasColumnName("idaddressType") _
                    .IsRequired() _
                    .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity) _
                    .HasColumnType("bigint")
            Me _
                .Property(Function(p) p.Description) _
                    .HasColumnName("description") _
                    .IsRequired() _
                    .HasMaxLength(45) _
                    .HasColumnType("varchar")
            ' Association:
            Me _
                .HasMany(Function(p) p.Addresses) _
                    .WithRequired(Function(c) c.Addresstype) _
                .HasForeignKey(Function(p) New With {p.IdAddressType}) _
                    .WillCascadeOnDelete(False)
            OnCreated()
        End Sub

        Partial Private Sub OnCreated()
        End Sub

    End Class
End Namespace

The problem occurs in AddressType config when trying to add the association with Address.
Exception:
InvalidOperationException
The properties expression 'p => new VB$AnonymousType_1`1(IdaddressType = p.IdAddressType)' is not valid. The expression should represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.



The other problem (not sure if it is by design):

When setting the Model setting "Preserve schema name in storage" to "false", no associations between tables (1:n relationships) are created neither in the diagram nor in the configuration classes.

Software:
- DotConnect MySQL 8.4.583
- Entity Developer 5.8.782
- Entity Framework 6
- Visual Studio 2015 Update 1
- MySQL 5.7

Can someone help me plz?
Thanks

Scheurich

Re: VB.NET Template problem with navigation properties (code first)

Posted: Wed 03 Feb 2016 19:16
by Shalex
scheurich wrote:The problem occurs in AddressType config when trying to add the association with Address.
Exception:
InvalidOperationException
The properties expression 'p => new VB$AnonymousType_1`1(IdaddressType = p.IdAddressType)' is not valid. The expression should represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.
Please send us a small test project with the corresponding DDL/DML script so that we can reproduce the error in our environment.
scheurich wrote:When setting the Model setting "Preserve schema name in storage" to "false", no associations between tables (1:n relationships) are created neither in the diagram nor in the configuration classes.
Please specify here (or send us) the DDL script of the corresponding two tables so that we can reproduce the issue.

Re: VB.NET Template problem with navigation properties (code first)

Posted: Thu 04 Feb 2016 07:11
by scheurich
Shalex wrote:
scheurich wrote:The problem occurs in AddressType config when trying to add the association with Address.
Exception:
InvalidOperationException
The properties expression 'p => new VB$AnonymousType_1`1(IdaddressType = p.IdAddressType)' is not valid. The expression should represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.
Please send us a small test project with the corresponding DDL/DML script so that we can reproduce the error in our environment.
scheurich wrote:When setting the Model setting "Preserve schema name in storage" to "false", no associations between tables (1:n relationships) are created neither in the diagram nor in the configuration classes.
Please specify here (or send us) the DDL script of the corresponding two tables so that we can reproduce the issue.

Just sent you the whole Project with SQL Script.
Thank you

Re: VB.NET Template problem with navigation properties (code first)

Posted: Fri 05 Feb 2016 13:59
by Shalex
scheurich wrote:The problem occurs in AddressType config when trying to add the association with Address.
Exception:
InvalidOperationException
The properties expression 'p => new VB$AnonymousType_1`1(IdaddressType = p.IdAddressType)' is not valid. The expression should represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.
We have reproduced the problem with the DbContext (VB) template. We will notify you when it is fixed.
scheurich wrote:When setting the Model setting "Preserve schema name in storage" to "false", no associations between tables (1:n relationships) are created neither in the diagram nor in the configuration classes.
We have asked for an additional information by email.

Re: VB.NET Template problem with navigation properties (code first)

Posted: Tue 09 Feb 2016 10:45
by Shalex
The code generation by the DbContext template (fluent mapping) for navigation properties is fixed. We will notify you when the corresponding build of dotConnect for MySQL is available for download.

Re: VB.NET Template problem with navigation properties (code first)

Posted: Thu 11 Feb 2016 15:17
by Shalex
The new build of dotConnect for MySQL 8.4.592 is available for download: http://forums.devart.com/viewtopic.php?f=2&t=33200.