I would recommend you to not use the "attach database through connection string"-feature in the first place.
Reason 1: It's only supported for SQL-Server Express editions. If you want your application to be able to use 'higher' editions of SQL-Server, it won't work anyway.
Reason 2: Microsoft recommends to stop using this feature because they are considering to remove it in a future version.
The alternative is completely trivial: Use SQL Server Management Studio to attach your database, making it a regular, permanent database. If you want to move your project to some other PC you can just either detach it or make a backup and attach it again on the other PC.
Edit after the question was updated:
It's possible to attach a database (an .mdf-file) programmatically. That is, you could let your application perform what I've mentioned in the paragraph above. In combination with my arguments for not using your current approach this could only serve to strengthen your point of proving your knowledge about C#, .NET and SQL-Server.
Please refer to this Codeproject-article:
Programmatically Enumerating, Attaching, and Detaching SQL Server Databases[
^]
And, if needed, you could find further information on that with this Google search:
https://www.google.com/search?q=sql+server+attach+database+programmatically[
^]