Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics Entity Framework and Databases Changing the Database Name

David Lin
David Lin
35,864 Points

connectionStrings for Context now needs providerName key

I get a run-time error if I don't specify providerName = "System.Data.SqlClient" in the connectionStrings for Context. This was not specified in the video.

<connectionStrings>
    <add name="Context" providerName="System.Data.SqlClient" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=myDatabase;Integrated Security=True;MultipleActiveResultSets=True"/>
</connectionStrings>
James Churchill
James Churchill
Treehouse Teacher

David,

The video shows adding the providerName attribute (see https://teamtreehouse.com/library/changing-the-database-name?t=350). Are you suggesting that the video should have made it clear that you'd get an exception if you don't provide that attribute?

Thanks ~James

David Lin
David Lin
35,864 Points

Thanks James ...

What must've happened was that I used the video slider controls to get to spot in the video to see the 1st line of the connectionStrings, but didn't go further to see where you added the providerName in the 2nd line.

So, that's why I got the error, since the 1st line was incomplete, and that's all I originally provided.

Thanks!