I’m developing an MVC 3 application, and thought about using ASP.NET’s default users, roles and profiles implementation. I created the aspnetdb database and can authenticate users very quickly – no problem.
The problem begins when I want to associate things with users. For instance, I want users to upload images – each image should be associated to the user who uploaded it.
If the aspnet_Users table wasn’t in a different database, I would have just added a UserId column to the Images table, set the appropriate foreign key and not worry about it anymore. That’s the straightforward way used in Django as well. Unfortunately, SQL Server 2008 doesn’t support foreign key constraints between databases.
I can create all the ASP.NET tables in my main database, but I’m not sure of the downside.
This issue is probably encountered by anybody creating an ASP.NET application. What’s the best practice?
You should be adding the asp.net membership provider tables to your main database. The only reason I can think that you wouldn’t do this is if they are self contained (e.g. you’re creating an access control project).