locked
Problem with Default code GenerationStrategy RRS feed

  • Question

  • Hi

    I've got a problem running Entity Framework 5 under .NET 4.5.

    - I'm using a fully patched up Visual Studio 2012 under Windows8.
    - Having created a new test class library project I add a new "ADO.Net Entity Data Model" and specify that I want to "Generate from Database".
    - I then accept defaults for names and provide (and successfully test) my connection to a very simple db in SQL Express 2008R2

    This appears to work correctly at this stage and I am presented with design representation of my (single table) database in the edmx file.
    Any code references that I now make appear to work and I'm relatively comfortable that so far all is good.

    My problem is appears when I now want to change the edmx Code Generation Strategy from "None" to "Default". (Now I'm new to the Entity Framework and ultimately might not need/want to do this however for now I am trying to get some code from a book working, which appears to assume that the Code Generation Strategy is"Default").

    When I do this a build on the projct creates a string of errors that start off with:

    Error 1 Partial declarations of 'SampleEntitFramework.SampleDbEntities' must not specify different base classes D:\Projects\SampleEntitFramework\SampleEntitFramework\ContactsDBModel.Context.cs 16 26 SampleEntitFramework

    Am I missing something? Is there a fuller process that needs to be folowed to use the "default" Code Generation Startegy?

    Here's the App.config that is generated...


    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <add name="SampleDbEntities" connectionString="metadata=res://*/ContactsDBModel.csdl|res://*/ContactsDBModel.ssdl|res://*/ContactsDBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ASUSLAPTOP\SQLEXPRESS;initial catalog=SampleDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
      </entityFramework>
    </configuration>

    Tuesday, January 8, 2013 4:33 PM

Answers

  • Fixed - apprently you need to delete the tt files ...that you get by default even if your intention was to use defult code generation....nasty.

    See Fernando Soto's very good answer here...

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/cb76200f-387e-4e72-9f35-8c2a56f3e020

    • Marked as answer by DaveSCT Tuesday, January 8, 2013 5:39 PM
    Tuesday, January 8, 2013 5:39 PM

All replies

  • Fixed - apprently you need to delete the tt files ...that you get by default even if your intention was to use defult code generation....nasty.

    See Fernando Soto's very good answer here...

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/cb76200f-387e-4e72-9f35-8c2a56f3e020

    • Marked as answer by DaveSCT Tuesday, January 8, 2013 5:39 PM
    Tuesday, January 8, 2013 5:39 PM
  • Hi Dave,

    Glad to know you find the answer by yourself. Thank you for sharing.

    Good day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 9, 2013 1:29 AM