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 Ford9,230 Points
Pulling 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?
var title = "SELECT title FROM artists";
Then pass it to the view?
James ChurchillTreehouse Teacher
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:
Then take a look at this course which will show you how to use EF with 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:
I hope this helps!