Insert data using LinqPad and Entity Framework

Is there a way to insert data using LinqPad and entity framework?

To create an Add or AddObject you need a Context. I can not find how to get this link.

I tried to do one, but then I go through this error:

ArgumentException: The specified named connection is either not found in the configuration, not intended for use with the EntityClient provider, or is invalid.

Does anyone know a cool way to insert / update in LinqPad using Entity Framework?

+4
source share
3 answers

I missed the connection string.

I had to copy the connection string from my App.config file (replacing " with ' ) and placing it in the constructor of my ObjectContext.

After I did this, everything worked out fine.

+1
source

To use the Entity Framework from LINQPad, you will need an existing data context, since LINQPad can only create LINQ-to-SQL data contexts (if you do not already have a project with this data context, create it and build it)

  • Click Add Connection on the left side of LINQPad.
  • Select "Use a typed data context from your own assembly."
  • Select "Entity Framework" from the list.
  • Click "Next>".
  • In Custom Assembly Path, enter the path to the DLL / EXE file containing the EF data context.
  • In the "Full name of the typed ObjectContext," click "Select" to find the EF data context, and the same for "Data Model for the Object."
  • Configure database connection settings.
  • Click Test to make sure everything is working.
  • Click "OK" - you are ready to go.
+6
source

if you use the C # program type, this.Connection.ConnectionString will provide you with a connection string, which you can then pass to the context ctor.

0
source

All Articles