Hi I already read many articles about simple membership but I'm still confused about the concept. I'd like to apply simplemembership to my existing database UserProfile table. I have MVC4 Internet application. So I decided to modify (WebSecurity.InitializeDatabaseConnection). As I understand, It create a table if there is no co-responding table in the database. But I'm wondering what is up about AccountModels.cs class if I already have UserProfile in my edmx? AccountModels.cs already have several kinds of model class related to simplemembership. What is happening to this classes if I hook up UserProfile from database?
Related
I'm using Identity 3 and I want to add some columns in AspNetUser table.
I've tried to do it using EF Core Code first and it's working well but I need to do it DB first.
I was wondering, if I will create the columns manually in database, then create the ApplicationUser class with corresponding properties, will it work?
Yup that should work, I've done it before.
However as time goes on I ended up having to add so many that it got messy.
So eventually I refactored those extra columns into their own related tables:
e.g: User_AdditionalDetails
This was a massive pain as I had live users and had to write scripts to migrate everyone's data etc.
This way you would only need to add a single FK for the related table with all this extra info.
It also neatens the code too, and gives the benefit of being able to load different sets of user properties only when they are needed.
If it's for an application scope property of the user like 'Region' which determines behaviour of core functionality of your app, then I'd say add it straight onto the main ApplicationUser class.
I want to create the design of a SQL database that will hold the data entered from a dynamic created websites (something like http://www.wufoo.com).
Users of the system will create forms by dragging controls into the form and then they will use the created forms to build a website by including the forms in some pages.
What would be the options that I have when I create the architecture of the database.
Since you do not know what you will get in your DB, how the object will look like; I would suggest using NoSql.
Otherwise you need to create some very abstract table, let's say Form, and then make in inheritable by other tables (ye, you can do that in EF)
I know that each time a user registers in my ASP.NET MVC application the ApplicationUser class is used to create the new record and put it in the database.
I was wondering if it's okay to add properties to that class for example I want the model to have a column in the database for DateOfBirth. Then use that class(model) directly in my application when I have to do some business logic things, database queries and similar stuff. Or is it more correct to create a new table in the database called let's say ApplicationAccounts, that saves the general info about the account. Each ApplicationAccount will be associated with a ApplicationUser(1 to 1 relation) and be somewhat of a buffer in the communication with the real accounts. Does that make sense?
I would go with the second option : create your own table, link them up in a one to one relationship using the UserID as a unique foreign key and then go from there.
One note here, it is perfectly normal for the model you need for the views to be different from the database model, this is because your db model can hold a lot of data that your view doesn't actually need. You might want to consider having separate models and use something like Automapper for a quick translation from one to another.
I have an ASP.NET MVC 5 web app. I have connected to a database on localDB ("MyWebAppDatabase"), which already contains many tables. I am accessing this using ADO.NET Entity Framework, and this is all working great.
However, I would like to add a table which references users who use the website: I have a "Subscription" table and would like to associate it with an ApplicationUser. The problem is that the tables containing user information are stored in a separate database (which was automatically generated by the Visual Studio when I created the project under the DefaultConnection context), and I don't know how I can perform this association.
What is the best way to go about this? I thought the ideal solution would be if I could move the tables that ASP.NET automatically created for application users into MyWebAppDatabase - then I can easily update the database with the correct tables and foreign keys. Is this correct? If so, how would I go about doing this? I'm not entirely sure where the database is for the application users (I couldn't decipher it from looking at Web.Config and reading the DefaultConnection connection string) and I don't really understand how I would be able to migrate the tables.
Thank you all for your help!
Ideally if you can move the tables into a single database you will get the best performance, otherwise you will have to do all of the JOIN's in memory in the application. You can't make foreign key references across database unfortunately.
If you point the connection string for the ASP.NET Identity to the same database that your Subscription table is located in and run the application and create some users it should create those tables automatically.
I am implementing Membership and security in my MVC4 website using custom database. Every things working fine but when I used .EDMX(Designer) to add my database tables membership and security starts giving errors. I also know the reason: This is due to duplicate Class files as default membership use code first approach and I am using database first approach. My question is there is any soluton that I can work using database first(EDMX) and also my security and membership functionality works fine.
Thanks.
The following post details the steps to take when using SimpleMembership with a Database-First approach: Using MVC 4 SimpleMembership with an existing database-first EF model
Also, you may find the following link has some useful information about SimpleMembership: http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx