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"?>
        <!-- For more information on Entity Framework configuration, visit -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <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" />
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
            <parameter value="v11.0" />

    Any help is greatly appreciated.


    Monday, December 1, 2014 5:09 PM


  • 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

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