none
EDMX insert RRS feed

  • Question

  • I have a small app I am trying to learn some LINQ with.  I have created 1 address table and dropped an EDMX file in my class library.  I have created the following:

    namespace DAL { public class DB { public int insertIntoAddressTable(Address address) { using (TestEntities ctx = new TestEntities()) { ctx.Addresses.Add(address); int intRC = ctx.SaveChanges();

    return intRC; } } } }

    I am passing in the data in the address parameter and all I need to do is insert into the DB. I get the following error:

      Message "No connection string named 'TestEntities' could be found in the application config file." string

    Here is my app.config:

    <?xml version="1.0" encoding="utf-8"?>
    <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="TestEntities" connectionString="metadata=res://*/AddressData.csdl|res://*/AddressData.ssdl|res://*/AddressData.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\v11.0;initial catalog=Test;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
    </configuration>

    Any help is greatly appreciated.

    Thanks

    Monday, December 1, 2014 5:09 PM

Answers

  • Move the app.config settings to the app.config of your .exe project

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    • Marked as answer by skister77 Monday, December 1, 2014 6:05 PM
    Monday, December 1, 2014 5:39 PM