Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jake Ford
9,230 PointsPulling data from MySQL database via the Controller?
So would it be possible to connect to a MySQL database and pull content from there rather than adding static content to the Controller? I have used PHP and MySQL before, but never with .NET. Any good information on doing something like this?
Something like:
var title = "SELECT title FROM artists";
Then pass it to the view?
1 Answer

James Churchill
Treehouse TeacherJacob,
Absolutely, yes! I'm not introducing querying data from a database in the course in order to keep the focus on learning MVC. In the .NET world, developers often use Entity Framework to work with databases, but you could use ADO.NET as well.
If you want to learn about Entity Framework, check out our course that'll teach you the basics:
https://teamtreehouse.com/library/entity-framework-basics
Then take a look at this course which will show you how to use EF with MVC:
https://teamtreehouse.com/library/entity-framework-with-aspnet-mvc
We use SQL Server LocalDB for our databases in those courses. If you want to connect to a MySQL database, check out this provider for EF:
https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html
I hope this helps!
Thanks ~James
Jake Ford
9,230 PointsJake Ford
9,230 PointsThank you, I'll check out these courses for sure.