Using the old aspnet membership with aspnet vNext - asp.net-membership

UPDATE November 20, 2015
How can I authenticate against a database that have the users stored using the Old Membership Provider ? (the aspnet_* tables)
Knowing that this database is used by other applications, so I don't have the option to migrate (or change) the database ?
For whom looking for migration look at Maxime Rouiller's answer
Old Question
Can I use the aspnet Membership with aspnet vNext ?,
In my situation I can't migrate the old database, because I am building a new app/ui interface for an existing one based on the old Membership provider
It will be a good idea if I can write some code to login without using the old Membership
What needed exactly is to just validate the user against the hashed password, (no registration, no forgot password, etc ...)
I prefer to not rely on the .net 4.x, and using the core50 (if available) instead (since I am planing to host it on linux later)

No. The old membership was dependent on the web.config being present and also was heavily dependent on the System.Web lifetime.
You are looking for a migration from your old membership to the new Identity 3.
The database should be easily portable. If you are planning to have it hosted on Linux, I would go as far as remove the dnx451 dependency altogether and just keep dnxcore50.
Tutorials:
http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity
http://travis.io/blog/2015/03/24/migrate-from-aspnet-membership-to-aspnet-identity/

Related

How to generate model classes for existing oracle database in asp core 2.2?

I'm trying to make database first approach in asp core 2.2.
My problem is that I can't find anything helpful to generate my model classes from my existing oracle database, I want to do it by anyway I don't care, but all my attempts failed so any help would be much appreciated
Edit 1:
I see that EF Core is always mentioned in the answer but it has no provider, I'm not sticking to it I'm really asking for any approach to do what I want so if there is a way with Dapper, NHibernate or anything else I will be happy to use it as it get the job done.
Edit 2:
I tried Devart.Data.Oracle.EFCore, it generates classes based on database tables like a charm but it's paid unfortunately. later I used Dapper and had to create classes on my own.
Seems like Oracle is currently conducting a private beta of their EF Core provider. You could either try to join the beta or keep waiting for the release of the public beta, which is announced for Dec., 2018 (seems to be delayed).
A documentation about reverse-engineering yor db can be found here.
There are several tools in the market
Devart's Entity Developer
Scaffold-DbContext or dotnet ef dbcontext scaffold
EF Core Power Tools
Edit
Right now, Oracle does not have support for Entity Framework Core. Which means you need to use third party library in order to use Entity Framework Core with Oracle.
Devart has dotConnect for Oracle Database Driver (adapter) which supports EF Core.
Please see this link for Future Plans about Oracle Database Providers
Edit: OP Stated that Only Mapping/Scaffolding will be enough
You may consider to use Entity Framework to scaffold your model and migrate it to EF Core Manually.You may need little tweaks since two framework has some differences.
Try using this provider https://github.com/CrazyJson/Citms.EntityFrameworkCore.Oracle
You can download it from NuGet-solution - Citms.EntityFrameworkCore.Oracle
Make sure you've installed its dependencies:
Oracle.ManagedDataAccess.Core (>= 2.18.3)
Microsoft.EntityFrameworkCore.Relational (>= 2.2.0)
For anyone who is coming in later, this was finally solved by oracle itself as they released their provider for EF core Oracle.EntityFrameworkCore.
Then follow the docs but use Oracle.EntityFrameworkCore and the proper connection string

Screwturn wiki to point to existing database will not work

I recently moved my screwturn installation to a completely new environment (site on new IIS/server and database moved to new SQL Server).
I can succesfully open the Screwturn wiki but instead of using the existing database (that I configured in the web.config), Screwturn wants to create the DB from scratch and hence states the error that certain tables already exist in the DB.
If I create a blank DB and use this in the web.config, Screwturn will happily create its tables and use that DB. Of course, that's not what I want, I want it to use the existing, moved DB on the server.
Is there a way to tell Screwturn not to create the DB and simply "use" the existing one?
If this is not possible, are there scripts available to copy the content from the old DB to the new one (simply copying it with SQL Servers Import/Export feature gives errors (logical) that certain fields cannot be created as that will cause PK violations.
Did you use your old web.config or just update the SQL connection info in the web.config from the new version? I think you should use your old web.config (maybe compare to the new one to see if anything was added). I have done this several times with several installations and haven't had a problem.
The only other thing I can think of off-hand is if your old version is v2, then you should review the instructions here as a few things changed from v2 to v3.
Old Screwturn Wiki Site - Upgrade from v2 to v3

Why do I need to explicitly enable data migrations in Azure?

I'm working through this tutorial:
Deploying an ASP.NET Web Application to a Windows Azure Web Site and SQL Database
In the second part "Enable Migrations and create the database" I need to use the NuGet Package Manager console to enter a series of commends:
enable-migrations -ContextTypeName ToDoListApp.Models.ToDoDb
add-migration-initial
update-database
Why do I need to do this explicitly? Shouldn't this be wrapped up in the publish process?
Thanks
Dave
The migrations process is separate from Azure. You can have an MVC 4 project that uses database migrations but the database is not hosted on Azure. The commands you are referencing simply enable the migrations in any MVC 4 project.
I find updating the database dangerous, so I actually prefer it to be separated from the publishing process because this way someone on your team is able to update the logic of the website without pushing updates to the database.

What do the ASP.NET Universal Providers enable that the default sql providers don't?

Inside the readme file of the ASP.NET Universal providers NuGet package is this quote
The SqlMembershipProvider, SqlRoleProvider, SqlProfileProvider classes that shipped in ASP.NET through version 4 support only Microsoft SQL Server and Microsoft SQL Server Express. They do not support newer offerings such as Microsoft SQL Azure and Microsoft SQL Server Compact.
However, when I run the custom aspnet_regsql scripts for Sql Azure http://support.microsoft.com/kb/2006191 and then point my web.config to the SQL Azure database, ASP.NET membership seems to work correctly.
Can anyone tell me what exactly doesn't work with SQL Azure, that the universal providers enable?
The main difference, as far as I can tell, is that when you connect to Sql Azure you need to implement retry logic. The original providers won't retry when a connection error occurs and this will happen from time to time with SQL Azure.
Also, the original providers don't raise exceptions containing the full SQL error codes so if your database is being throttled you won't know which throttling rule is being applied. At least this is what the SQL Azure support team tell me - I'm currently in the process of upgrading for this reason.
A note of caution: the Universal Providers seem to use a different database schema to the original providers, so you will need to migrate membership data. If you are starting a new project it will be much easier to change these providers before you go live with real users!
the universal providers enable you to use asp.net membership system on sqlazure and also make the implementation sql agnostic. you can take the same app using universal providers and change the datasource to be sql server/sqlexpress/sqlce/localdb etc

How to add a foreign key, through the interface, to ASPNET Membership provider?

I'm using VWD 2008 Express Edition with MVC and I am trying to add a foreign key from my database to the ASPNET Membership database's Users table. Is this possible using the user interface or do I have to scrounge up some SQL every time I want to do this?
Edit: After thinking about this for a minute, I realized that maybe having an FK to a different DB wasn't even possible... I really didn't think about my question thoroughly enough, did I?
There is no API for that. Script your database once you created the membership tables and use your script from there on. (BTW, you don't have to use that table structure to use the membership provider if it doesn't suit your needs.)

Resources