Skip to content

Instantly share code, notes, and snippets.

@diffused
Created November 20, 2013 14:12
Show Gist options
  • Select an option

  • Save diffused/7563830 to your computer and use it in GitHub Desktop.

Select an option

Save diffused/7563830 to your computer and use it in GitHub Desktop.
Example Entity Framework 6 context using connection string in app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Store" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=Store;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
public class StoreContext : DbContext
{
// base name=[ConnectionStringName]
public StoreContext() : base("name=Store") { }
public DbSet<Product> Products { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment