So.
At first, i added connection string to remote server MSSQL Server 2008 R2, 10.50.1600:
<add name="MySQLConnection" connectionString="server=xxx.x.xx.xx;initial catalog=xxxxx;user id=sa;password=xxxxxxxxxxx;"/>
Then, i configured that remote database using aspnet_regsql in .NET 4.0 on server side and add custom membership (because inbuild didn’t want to work with WSAT).
<membership
defaultProvider="SqlProvider"
userIsOnlineTimeWindow="20">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MySQLConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
passwordFormat="Hashed"
applicationName="/" />
</providers>
</membership>
So, now i can configure my application with WSAT, but can’t enter on login or register page, get error:
System.ArgumentException: Invalid value for key 'attachdbfilename'.
Line 32: using (var context = new UsersContext())
Line 33: {
Line 34: if (!context.Database.Exists())
Line 35: {
Line 36: // Create the SimpleMembership database without Entity Framework migration schema
SOLVED:
The problem was here:
public class UsersContext : DbContext
{
public UsersContext()
: base("DefaultConnection")
{
}
public DbSet<UserProfile> UserProfiles { get; set; }
}
I dont need custom membership e.t.c.- just to set for my connection string current DefaultConnection name, or change here to MySQLConnectionString.
attachdbfilename is not valid for remote databases. It says your connection name is MySQLConnection, but in your membership you specify a connection string of “dbSkazkiEntities”.
Are there more than one connection string?
EDIT:
Wow. Ok, you have a ton of things messed up here. First, you are using SimpleMembership. SimpleMembership does not use a Membership provider configured in your Web.Config. It does absolutely nothing.
Second, SimpleMembership is configured in the Filters\InitializeSimpleMembershipAttribute.cs file, in there is a line that says:
The first parameter tells SimpleMembership which connection string to use, and it’s called DefaultConnection. DefaultConnection is a fallback connection defined in machine.config, and this connection uses a localdb by default, which has the attachdbfilename attribute.
You need to change the line above to be your MySQLConnection instead, and get rid of the MembershipProvider you created.
Next up is that the UsersContext is defined with a default connection string as well. Change that as well.