Using MVC3, VS 2010 and SQL Express, I have been successful getting through a few tutorials. What I'd like to do now is build my own app which will be deployed. Using Code First, I'd like to have my user authentication and data reside in the same database. From what I've read, it is possible, (acceptable?) but so far I have not found any info on how to get my models and membership to map to the same database - I would like to specify a different DB than aspnet.mdf.
1 Answer
For the membership tables you can use the aspnet_regsql.exe tool on the command line.
Specify the database and credentials and it will create the membership tables on that database.
You can point the Entity Framework to the same database.
This way, both membership and EF will be living in the same database.
4 Comments
Brian
assuming I'm using code first, to follow your suggestion, I would have to create my models and my database first - correct? I'm starting from a fresh MVC web project with the default connection string pointing to apsnet.mdf.
Oded
@Brian - Then you can invoke
aspnet_regsql passing in the connection string to this database.Brian
OK - not familiar with this tool, but the connection string uses integrated security = SSPI. No user name or password. Will that work?
Oded
@Brian - If you run it under the same credentials that your application runs under (I will assume that this is your account, which should be fine).