cancel
Showing results for 
Search instead for 
Did you mean: 

Error on Model generation (Entity Framework Database First )

Former Member
0 Kudos
5,870

Hello guys,

today I tried to generate a model for a provided demo db (Visual Studio 2013 Update 5, Sql Anywhere 17.0.4.2053, Entity framework 5.0.0 ) and I got in the output window of VS the exception :The model was generated with warnings or errors.Model.edmx Please see the Error List for more details. In my edmx file I can see : Errors Found During Generation: error 6004: The table '.GROUPO.Customers' is referenced by a relationship, but cannot be found. error 6004: The table '.GROUPO.Contacts' is referenced by a relationship, but cannot be found. <Association Name="FK_Contacts_5_Customers"

What I'm doing wrong?

Regards, Boris

jack_schueler
Advisor
Advisor
0 Kudos

It would be handy to know what steps you are performing. Are you following the Database First to an existing database tutorial at http://dcx.sap.com/index.html#sqla170/en/html/37fb9e8558e94547b66156b9298be16f.html ?

Former Member
0 Kudos

Thank you for your enquiry, I installed VS Wizard with SetupVSPackage.exe /i option, I checked also .Net Version: it has to be NET 4.0 in our case, I'm using the ODBC data source to the demo database test connection to which was successfull, in my app.config I can see the following lines:

<configuration> <configsections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirepermission="false"/> </configsections> <connectionstrings> <add name="Entities3" connectionstring="metadata=res://*/Model3.csdl|res://*/Model3.ssdl|res://*/Model3.msl; provider=Sap.Data.SQLAnywhere;provider connection string='UserID=dba;Password=sql; DataSourceName="SQL Anywhere 17 Demo"'" providername="System.Data.EntityClient"/> </connectionstrings> <entityframework> <defaultconnectionfactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> <providers> <provider invariantname="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> </providers> </entityframework> </configuration>
Former Member
0 Kudos

I tried with .NET 4.5 & EF6, it works like expected, with this app.config genaration run successfully :

<configuration>
  <configsections>
    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirepermission="false"/>
  </configsections>
  <startup>
    <supportedruntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <system.data>
    <dbproviderfactories>
      <clear/>
      <add name="SQL Anywhere 17 Data Provider" invariant="Sap.Data.SQLAnywhere" description=".Net Framework Data Provider for SQL Anywhere 17" type="Sap.Data.SQLAnywhere.SAFactory, Sap.Data.SQLAnywhere.EF6, Version=17.0.0.10094, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/>
    </dbproviderfactories>
  </system.data>
  <entityframework>
    <defaultconnectionfactory type="Sap.Data.SQLAnywhere.SAConnectionFactory, Sap.Data.SQLAnywhere.EF6, Version=17.0.0.10094, Culture=neutral, PublicKeyToken=f222fc4333e0d400">
    </defaultconnectionfactory>
    <providers>
      <provider invariantname="Sap.Data.SQLAnywhere" type="Sap.Data.SQLAnywhere.SAProviderServices, Sap.Data.SQLAnywhere.EF6, Version=17.0.0.10094, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/>
    </providers>
  </entityframework>
<connectionstrings><add name="Entities" connectionstring="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Sap.Data.SQLAnywhere;provider connection string='UserID=dba;Password=sql;DataSourceName="SQL Anywhere 17 Demo"'" providername="System.Data.EntityClient"/></connectionstrings></configuration>

But what should we do, if we use previos versions of sql anywhere /EF ? E.g. I tried to generate model with the following app.config (which failed with foreign keys and navigation properties) :

<configuration>
  <configsections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,  EntityFramework, Version=4.4.0.0,  Culture=neutral, PublicKeyToken=b77a5c561934e089" requirepermission="false"/>
    
  </configsections>
  <startup>
    <supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.data>
    <dbproviderfactories>
      <clear/>
       <add name="SQL Anywhere 11 Data Provider" invariant="iAnywhere.Data.SQLAnywhere" description=".Net Framework Data Provider for SQL Anywhere 11" type="iAnywhere.Data.SQLAnywhere.SAFactory, iAnywhere.Data.SQLAnywhere.v4.0, Version=11.0.1.29604, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/>
    </dbproviderfactories>
  </system.data>
  <entityframework>
    <defaultconnectionfactory type="iAnywhere.Data.SQLAnywhere.SAFactory, iAnywhere.Data.SQLAnywhere.v4.0, Version=11.0.1.29604, Culture=neutral, PublicKeyToken=f222fc4333e0d400">
    </defaultconnectionfactory>
    <providers>
      <provider invariantname="iAnywhere.Data.SQLAnywhere" type="iAnywhere.Data.SQLAnywhere.SAProviderServices, iAnywhere.Data.SQLAnywhere.v4.0, Version=11.0.1.29604, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/>
    </providers>
  </entityframework>
<connectionstrings><add name="Entities" connectionstring="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=iAnywhere.Data.SQLAnywhere;provider connection string='DataSourceName="SQL Anywhere 11 Demo"'" providername="System.Data.EntityClient"/></connectionstrings></configuration>
Former Member
0 Kudos

I tried also with
<entityframework> <defaultconnectionfactory type="iAnywhere.Data.SQLAnywhere.SAConnectionFactory, iAnywhere.Data.SQLAnywhere.v4.0, Version=11.0.1.29604, Culture=neutral, PublicKeyToken=f222fc4333e0d400"> </defaultconnectionfactory> <providers> <provider invariantname="iAnywhere.Data.SQLAnywhere" type="iAnywhere.Data.SQLAnywhere.SAProviderServices, iAnywhere.Data.SQLAnywhere.v4.0, Version=11.0.1.29604, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/> </providers> </entityframework> it doesn't work as exprected

VolkerBarth
Contributor
0 Kudos

FWIW, I used a pair of pre-tags to format the code as-is... (but don't know the answer, sorry...)

jack_schueler
Advisor
Advisor
0 Kudos

I see you are using Version=11.0.1.29604.

You'll have to upgrade to a newer version (preferably 17.0) to get the most up-to-date Entity Framework support. Version 11.0.1 and 12.0.1 are no longer supported.

Former Member
0 Kudos

Thanks for your suggestion and nice formatting, the problem is that some of our customers still use version 11.0.1.X, referred to https://wiki.scn.sap.com/wiki/display/SQLANY/Using+SQL+Anywhere+and+the+ADO.NET+Entity+Framework it is possible to use EF with Versions up SQL Anywhere 11.0.1.2427, isn't?

So how do we have to configure app.config in order to get it working with .NET 4.0 & EF 5.0.0 ?

Accepted Solutions (0)

Answers (0)