Mono, ASP.NET Membership provider and Guids - asp.net

I want to build an ASP.NET site using Mono and a non SQL Server database like Postgres or MySQL. ASP.NET uses Guids in their membership providers for UserIds, and so forth, and Postgres/MySQL don't deal so well with Guids.
What is the most common approach to dealing with Membership providers in Mono, so that user ids can be stored efficiently in the non SQL server database?

It is not a compulsion to to use Guid for userId in membership provider. You will be using official .Net providers. Both (Mysql and Postgres) have well maintained .Net providers. MySql provider has support for membership provider, so if you are using MySql you don't have to worry about Guid. I'm not sure about Postgres.
Anyway you can always implement your own membership provider, which I think is the best solution.

I'm not sure this is a common approach in Mono, but you might want to look at the Altairis Web Security Toolkit on CodePlex. It uses a simplified SQL model that doesn't include Guids. It should be easily adaptable to open source DB's such as MySQL and Postgres with its simple approach.
Altairis Web Security SQL Table Providers

Related

Connect MongoDB using Nhibernate in Asp.Net Core

Can I use nhibernate to connect MongoDb in Asp.Net Core. Do we need any additional driver to connect mongodb using nhibernate in Asp.Net Core?
NHibernate only works with traditional SQL database providers. You can see full list here: https://nhibernate.info/doc/nhibernate-features. MongoDB is not one of those, specifically because it's a NoSQL solution. There is no way to use NHibernate with it. You should use the API provided by the MongoDb.Driver package directly.

Difference between Entity Framework and Microsoft SQL Server

I'm fairly new to mvc, asp.net, and .net framework in general.
I understand what models are, controllers and views, but what I don't get it is Entity Framework. I developed websites before using php, and when I needed to store some data I simply do that using MySql databases. I thought this is the case with asp.net, same concept but instead of MySql, Microsoft Sql server is used. Now I started to learn .net framework and I watched a lot of online tutorials and saw them using some classes inherited from DbContext to store data! Can anyone tell me where these classes store the data and why don't we use Microsoft Sql server instead?
Entity Framework is an Object Relational Mapping tool (ORM), a layer that sits between your database and code. The idea is that the ORM is database agnostic and will handle writing the SQL for you, so that you could (in theory) swap between SQL Server, MySQL, or whatever database you want with only configuration changes.
You can skip Entity Framework and use SQL directly with ASP.Net. Your tutorials just happen to use Entity Framework.

What are my most optimal options on membership providers when using codefirst EF approach

I am building an MVC3 web app and new to .NET and programming in general.
I was thinking about using the built-in ASP.NET membership provider but it seems I would have to tip toe around it, unable to cleanly link users into the rest of my entity objects and it would be a separate database too.
I just need the basics Users, Roles, Password change/retrieval. The addresses and other user specific info I take it don't have anything to do with the membership provider tables ? As in I would just need a FK relationship with the UserID etc. in one of the respective membership tables?
From what I have been reading there are ways to inherit from ASP.NET Membership Provider and implement the abstract methods for use wit EF. If that is my best bet are there any good examples or tutorials on doing so?
Rolling my own would be quite difficult I suppose, but if there's a good guide on doing so with EF codefirst I'd gladly check it out. Or maybe there's already some recommended providers on codeplex?
PS. Using sql express and will be deploying to some cheapo webhost, prolly with 1x SQL server 2008 db limit.
Thanks..
You should look at MVC3 Boilerplate project on GitHub. It has EF integration with MembershipProvider, look specifically at the UserMembershipProvider classes.

ASP.Net: ASPNETDB can I implement LINQ to Sql with this DB?

Very new to membership provider and just implemented on my new web site. I thought it would be nice to be able to use LINQ to query the database. Can I implement LINQ to SQL on that database?
You shouldn't really be querying the database directly. There is a Membership API for that. It uses a pattern called the provider model which means that you can use the same API always and then swap out a different membership provider without having to change your site code.
You might want to do this to use an xml file, or a webservice, or an in-memory provider, but you should still be able to use the Membership API without having to worry about how the data is being retrieved.
If you do want to write some linq-to-sql code then you should write your own membershipprovider:
http://www.google.co.uk/search?q=asp.net+custom+membership+provider
BTW, If you are just getting started then you should be learning Entity Framework really because Linq-to-Sql has been kind of superseded by EF.
All the things rtpHarry said are right, generally you would use the membership API whenever you are within your ASP.Net application.
However, if you are querying your membership DB from another application for some reason, for example if you had a WinForms admin application or something, then you certainly can use Linq to SQL (or Entity Framework).

User authentication database in App_Data folder - isn't that dangerous?

We're planning to use standard ASP.NET user authentication for our application. However, by default this requires us to have our user database on our web server in the App_Data folder.
This is usually a big no-no for us - our databases are all behind the firewall and all access is done via a WCF Service layer.
If the database was on a different server, but directly accessible from the web server then this still vioates our usual architecture rules.
Should we worry about our user database living on our web server? Does ASP.NET offer an out-of-the-box alternative?
NOTE: We're using .NET 3.5 and SQL Server 2005
You can install the neccessary db tables etc. in any SQL Server database.
Use the aspnet_regsql.exe Wizard found in C:\WINDOWS\Microsoft.NET\Framework....... to set up the target database.
Then simply update the connection strings in the provider configurations in the web.config.
Yes and Yes.
If you ever need to move to multiple web servers you shouldn't have the user data on one of those servers.
There are multiple was to do this, but check out this link for details on one MSDN How To: Use Forms Authentication with SQL Server in ASP.NET 2.0
you can create your own Custom membership provider by overriding the methods and properties of the following abstract class: public abstract class MembershipProvider. Once you override them, then you can use any valid datasource to authenticate the user. For example, you can use MYSQL, SQL server or even XML file to authticate your users. These provider models are really really cool.
Yes, you should worry. No, there is no out-of-the-box solution. ASP.NET only ships with a SQL Membership Provider and an Active Directory membership provider (reference). You will have to use a custom membership provider to provide your functionality.

Resources