Adding tables to EDM

Last post 12-13-2007 3:22 PM by nbenami. 20 replies.

Sort Posts:

  • Adding tables to EDM

    12-10-2007, 12:05 PM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    I installed Visual Studio 2008 (release edition), ASP.Net Extensions and the EDM tools.

    Using the EDM designer I am able to setup a new model.

    When I try to add a table/view/sp using the described method in de documentation (Right click in the model view --> Update model from database...) the wizard opens as expected (connection parameter form).
    But when I click next (to go to the database object selection form) the wizard closes without any error or message.

    So... I am unable to add or remove any database objects (tables / views / etc.) from the EDM Store...

    Is there a possible workaround?

    Remco Ros
     

  • Re: Adding tables to EDM

    12-10-2007, 5:39 PM
    • Loading...
    • nbenami
    • Joined on 12-10-2007, 5:38 PM
    • Posts 3

    To understand this better: You started out by creating an empty model, yes? That would be why you are getting the connection parameter form first.

    Then, what do you put in for the connection information?

    Thanks,
      Noam Ben-Ami

  • Re: Adding tables to EDM

    12-10-2007, 6:30 PM
    • Loading...
    • mike.j.pappas
    • Joined on 12-10-2007, 5:56 PM
    • Fairfield, IA
    • Posts 9

    I'm having the same issue.  After auto-generating a model based of an existing database, I try to add another entity by right-clicking anywhere in the Model Browser.  The database screen appears for a second, then disappears.  I tried also manually adding an entity and trying to associate it to a table.  That tables that I already added show up but there is now way to add or type in another table.

  • Re: Adding tables to EDM

    12-11-2007, 6:24 AM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    It doesn't matter if you start with an empty model or not. The wizard appears and closes almost immediatly after.

  • Re: Adding tables to EDM

    12-11-2007, 12:42 PM
    • Loading...
    • nbenami
    • Joined on 12-10-2007, 5:38 PM
    • Posts 3

    We need enough information here to try and recreate the bug. Can you please tell us what you put in for the connection information?

  • Re: Adding tables to EDM

    12-11-2007, 12:58 PM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    The usual connection string to SQL Server:

    metadata=.\Data\Model1.csdl|.\Data\Model1.ssdl|.\Data\Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=mobielbereikbaar.nl\SQLExpress;Initial Catalog=telashop_ontwikkel;Persist Security Info=True;User ID=telashop;Password=***********" 

  • Re: Adding tables to EDM

    12-11-2007, 1:07 PM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    It looks like when the wizard opens, information IS retrieved from SQL Server. But when the information is retrieved, the window closes automatically. 

  • Re: Adding tables to EDM

    12-11-2007, 4:26 PM
    • Loading...
    • lajones
    • Joined on 12-11-2007, 6:36 PM
    • Posts 4

    Hmmm. If the wizard fails for any reason there's supposed to be a dialog that pops up saying what the failure is. Presume you're not seeing this (sometimes I've noticed the dialog getting hidden behind the Visual Studio window)?

    Other things that we can investigate - can you post your edmx file? Also, if it's available to you, can you try the same scenario that causes you a failure on a database which is SQL Server rather than SQLExpress - to see if SQLExpress has anything to do with it?

     Lawrence Jones (Microsoft)

  • Re: Adding tables to EDM

    12-11-2007, 5:16 PM
    • Loading...
    • mike.j.pappas
    • Joined on 12-10-2007, 5:56 PM
    • Fairfield, IA
    • Posts 9

    I have SQL 2005 (not SQLExpress) running on my development machine.  Here is my edmx file.

    <?xml version="1.0" encoding="utf-8"?>
    <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
      <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
        <edmx:Connection>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="MetadataArtifactProcessing" Value="CopyToOutputDirectory" />
          </DesignerInfoPropertySet>
        </edmx:Connection>
        <edmx:Options>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="ValidateOnBuild" Value="true" />
          </DesignerInfoPropertySet>
        </edmx:Options>
        <edmx:ReverseEngineer />
        <edmx:Diagrams />
      </edmx:Designer>
      <edmx:Runtime>
        <!-- CSDL content -->
        <edmx:ConceptualModels>
          <Schema Namespace="Test" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
            <EntityContainer Name="TestEntities">
              <EntitySet Name="Artist" EntityType="Test.Artist" />
            </EntityContainer>
            <EntityType Name="Artist">
              <Key>
                <PropertyRef Name="ID" />
              </Key>
              <Property Name="ID" Type="Int64" Nullable="false" />
              <Property Name="Name" Type="String" Nullable="false" MaxLength="250" />
              <Property Name="EmailPrefix" Type="String" MaxLength="250" />
              <Property Name="DateCreated" Type="DateTime" Nullable="false" />
              <Property Name="DateModified" Type="DateTime" Nullable="false" />
              <Property Name="IsActive" Type="Boolean" Nullable="false" />
            </EntityType>
          </Schema>
        </edmx:ConceptualModels>
        <!-- SSDL content -->
        <edmx:StorageModels>
          <Schema Namespace="Test.Store" Alias="Self" ProviderManifestToken="09.00.3054" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
            <EntityContainer Name="dbo">
              <EntitySet Name="Artist" EntityType="Test.Store.Artist" />
            </EntityContainer>
            <EntityType Name="Artist">
              <Key>
                <PropertyRef Name="ID" />
              </Key>
              <Property Name="ID" Type="bigint" Nullable="false" StoreGeneratedPattern="Identity" />
              <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="250" />
              <Property Name="EmailPrefix" Type="nvarchar" MaxLength="250" />
              <Property Name="DateCreated" Type="datetime" Nullable="false" />
              <Property Name="DateModified" Type="datetime" Nullable="false" />
              <Property Name="IsActive" Type="bit" Nullable="false" />
            </EntityType>
          </Schema>
        </edmx:StorageModels>
        <!-- C-S mapping content -->
        <edmx:Mappings>
          <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
            <EntityContainerMapping StorageEntityContainer="dbo" CdmEntityContainer="TestEntities">
              <EntitySetMapping Name="Artist">
                <EntityTypeMapping TypeName="IsTypeOf(Test.Artist)">
                  <MappingFragment StoreEntitySet="Artist">
                    <ScalarProperty Name="ID" ColumnName="ID" />
                    <ScalarProperty Name="Name" ColumnName="Name" />
                    <ScalarProperty Name="EmailPrefix" ColumnName="EmailPrefix" />
                    <ScalarProperty Name="DateCreated" ColumnName="DateCreated" />
                    <ScalarProperty Name="DateModified" ColumnName="DateModified" />
                    <ScalarProperty Name="IsActive" ColumnName="IsActive" />
                  </MappingFragment>
                </EntityTypeMapping>
              </EntitySetMapping>
            </EntityContainerMapping>
          </Mapping>
        </edmx:Mappings>
      </edmx:Runtime>
    </edmx:Edmx>

    I auto-generated a  model based on an existing database.  I pulled only one table that has existing foreign keys and a primary key in it.

    Strangely enough, when I create a model based on the Northwind database and pull in every table in the database, then try to update the model, the dialog appears and I can change the settings.  I can add/delete a table and so forth.  Just not my database!

    Filed under: ,
  • Re: Adding tables to EDM

    12-11-2007, 5:45 PM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    same thing on SQL Server.

    my edmx file (notice I started from a new empty model): 

      

    <edmx:Edmx Version="1.0"
        xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
    >
    
      <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
        <edmx:Connection>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="MetadataArtifactProcessing" Value="CopyToOutputDirectory" />
          </DesignerInfoPropertySet>
        </edmx:Connection>
        <edmx:Options>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="ValidateOnBuild" Value="true" />
          </DesignerInfoPropertySet>
        </edmx:Options>
        <edmx:ReverseEngineer />
        <edmx:Diagrams />
      </edmx:Designer>  
    
      <edmx:Runtime>
        <!-- CSDL content -->
        <edmx:ConceptualModels>
          <Schema
            xmlns="http://schemas.microsoft.com/ado/2006/04/edm"
            Namespace="AdWords"
            Alias="Self"
          >
            <EntityContainer Name="ModelContainer" />
          </Schema>
        </edmx:ConceptualModels>
    
        <!-- SSDL content -->
        <edmx:StorageModels>
          <Schema
            xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"
            Namespace="AdWords.Target"
            Alias="Self"
          >
            <EntityContainer Name="TargetContainer" />
          </Schema>
        </edmx:StorageModels>
    
        <!-- C-S mapping content -->
        <edmx:Mappings>
          <Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS" 
             Space="C-S"
          >
            <Alias Key="Model" Value="AdWords"/>
            <Alias Key="Target" Value="AdWords.Target"/>
    
            <EntityContainerMapping
              CdmEntityContainer="ModelContainer" 
              StorageEntityContainer="TargetContainer">
            </EntityContainerMapping>
          </Mapping>
        </edmx:Mappings>
      </edmx:Runtime>
    
    </edmx:Edmx>
    
     
  • Re: Adding tables to EDM

    12-11-2007, 6:55 PM
    • Loading...
    • lajones
    • Joined on 12-11-2007, 6:36 PM
    • Posts 4

    Both the edmx files look fine. It's odd that you can do Update Model from Database with Northwind but not with your own databases. The page of the wizard that's failing starts by kicking off 3 queries on the database to look up the tables, views and stored procs in order to show you what can be updated. It sounds like that's throwing an exception (although I would have expected any exception to be caught and shown to you in a dialog). Can you try executing the following query on your database by hand (using the login credentials stored in app.config or web.config) to see if there are any problems?

    SELECT

    t.Catalog, t.Schema, t.Name

    FROM SchemaInformation.Tables as t

    ORDER BY t.Schema, t.Name 

    and similarly for SchemaInformation.Views and SchemaInformation.Functions ?

    If that doesn't help then could you mail me the database/table creation scripts (at lajones at microsoft dot com - [altered to avoid screenscrapers]) and I'll try to mock it up here and see if I can repro the same thing.

  • Re: Adding tables to EDM

    12-12-2007, 7:16 AM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    Those queries are incorrect.

    below the correct query (and this works as expected): 

    SELECT t.table_Catalog, t.[table_Schema], t.table_Name
    FROM Information_schema.Tables as t
    ORDER BY t.[table_Schema], t.table_Name

    Also: Information_schema.Functions does not exists? 

    What are the exact 3 queries, so I can check it out?

  • Re: Adding tables to EDM

    12-12-2007, 7:58 AM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    edit: deleted
    I'll do some more profiling and testing... 

    I used SQL Server Profiler to intercept the correct queries. They get executed and return a totally valid result (I see no weird differences between my database and Northwind) apart from having more different schema's. But I also tested this by adding schema's and tables to Northwind. Still... Northwind works as expected.

    Is there some debug log or anything else I can inspect and/or test? 

  • Re: Adding tables to EDM

    12-12-2007, 8:36 AM
    • Loading...
    • TotaalIT
    • Joined on 12-10-2007, 4:57 PM
    • Posts 13

    Ok. I did all kind of tests: local, remote, sql server, sql express, Northwind / AdventureWorks databases, etc.

    Everything works, as long as I don't use my current database. 

    It seems the wizard just doesn't like the results coming from the information_schema queries to that database.

    I cannot post the database ddl here, cause it's too huge (lot's of tables, views, functions and procedures).

    Maybe there we have the problem too: Is it possible the wizard fails silently when the database contains too much objects then the wizard / edm tool can handle ?

  • Re: Adding tables to EDM

    12-12-2007, 11:09 AM