Is ASP.NET a simple membership provider?

I opened the Asp.Net Mvc 4. Internet application template. And I set the connection string for my database as follows:

<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=ALI-PC\;Initial Catalog=OsosPlusDb;Persist Security Info=True;User ID=sa;Password=sa;" providerName="System.Data.SqlClient" /> </connectionStrings> 

I started the project, click the registration button. I created a new user as follows:

enter image description here

When I click register to publish, I get this error:

enter image description here

But it creates a new user in the database and does not create member_user (the Membership table does not contain the user information added):

enter image description here

I can not find what the problem is. Sometimes an error does not occur.

UPDATE

And a snapshot:

enter image description here

AcoountModel:

 public class UsersContext : DbContext { public UsersContext() : base("DefaultConnection") { } public DbSet<UserProfile> UserProfiles { get; set; } } [Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } } 

InitializeSimpleMembershipAttribute.cs

 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute { private static SimpleMembershipInitializer _initializer; private static object _initializerLock = new object(); private static bool _isInitialized; public override void OnActionExecuting(ActionExecutingContext filterContext) { // Ensure ASP.NET Simple Membership is initialized only once per app start LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock); } private class SimpleMembershipInitializer { public SimpleMembershipInitializer() { Database.SetInitializer<UsersContext>(null); try { using (var context = new UsersContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); } catch (Exception ex) { throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex); } } } } 

LAST EDIT AND SUMMARY

The problem is the symbol ("i"). If I do not use "i", everything is fine. But when I use it, I got this error. How can I fix this problem.

+4
source share
3 answers

Create your database manually (do not allow your project to automatically create the database) and when you create the database set configuration for Latin1_General_CI_AS in the "Parameters" section.

OR

If you use the Turkish character in your database, then your data collection must be Turkish_CI_AS, and you can change the sorting of the columns. Follow the steps.

( PS: Sorting is sorting if you use the Turkish character, and if you want to sort as a, b, c, ç, d, e, f, g, h, ı, i, .. your database sort should be Turkish.)

1) Right-click on the "Username" column and select "Edit."

enter image description here

2) Click sort.

enter image description here

3) and select Latin1_General ..

enter image description here

Click OK and save your changes.

+8
source

I know it a little late, but the problem is to determine the sorting in your database. If you select the "TURKISH_CI_AS" sort when creating the database, the MembershipProvider does not work as expected.

+2
source

I assume that your membership tables are called incorrect or have invalid column names. Check a line similar to

 WebSecurity.InitializeDatabaseConnection( "StarterSite", "UserProfile", "UserId", "Email", autoCreateTables: true); 

in your AppStart.cshtml file.

See this link for more information: http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.initializedatabaseconnection(v = vs .111) .aspx

+1
source

Source: https://habr.com/ru/post/1439198/


All Articles