I've been using membership in vs2010 and never had a problem using it. Now i'm using VS2012 and am currently having trouble. In my Web Site Administration Tool, i get the error message "Unable to connect to SQL Server database." I have run the regsql file. I'm using mssql 2012 not the express version and working on a local project
<add name="XXXDbConnectionString" connectionString="Data Source=Local-PC;Initial Catalog=XXXDb;Integrated Security=True" providerName="System.Data.SqlClient"/>
<roleManager enabled="true" defaultProvider="SqlRoleManager">
<providers>
<add name="SqlRoleManager"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="MyConnectionString"
applicationName="MyApplication" />
</providers>
</roleManager>
Just had to insert to rolemanager
Related
I'm using Visual Studio 2012 for Web and I'm coding a MVC application. By default it uses a localDB but I want it on a SQL Server. I've installed SQL Server 2014 and my servername is C0208\SQLEXPRESS.
C0208 is my computer name
Named Instance: SQLEXPRESS
InstanceID: SQLEXPRESS
This is my connectionstring to the localdb
<add name="IssueContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=RecreationalServicesTicketingSystem;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\RecreationalServicesTicketingSystem.mdf" providerName="System.Data.SqlClient" />
I tried using this connection string and I don't know if it's correct or not
<add name="IssueContext" providerName="System.Data.SqlClient" connectionString="Data Source=C0208\SQLEXPRESS;User Id=C0208;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />
This looks more of an Entity Framework issue rather than the SQL connection string. Just check if you have updated the connection string everywhere. (app.config).
To Enable data migration you will have to run the following command in the Package Manager Console.
enable-migrations
if it gives an error than try the following command first
add-migration projectName
For more details check this link
I'm using EF code-first and I want it to create the new database in SQL Server Management Studio instance instead of using the integrated SQL Server in Visual Studio.
I added this to my web.config:
<connectionStrings>
<add name="BillFo"
connectionString="Data Source=SELANL293;Initial Catalog=Billfo;Integrated Security=True"/>
</connectionStrings>
But it doesn't help. No nothing happens, nothing in the integrated SQL Server and nothing in my SQL Server Management Studio. How do I make it create my database in Management Studio rather then the SQL Server in Visual Studio?
try add this section
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="connection string......"/>
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="..." providerName="System.Data.SqlClient" connectionString="......" />
</connectionStrings>
you do not have to use <parameters> property , you can use your currently connection string configuration
Try
<connectionStrings>
<clear />
<add name="YourEFContextName" connectionString="Data Source=localhost\SqlServerInstanceName; Initial Catalog=DataBaseName; User ID=UserName; password=YourPassword; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
The section entityFramework should be created automatically.
I have setup a local installation of DNN7 using a database residing in another machine (sqlserver 2008).
I've tried to copy all the filesystem to a production server but keep the connection string the same, so use the exact same database.
I get the message
"The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty."
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
The application pool and IIS settings are the same in both machines. Any ideas of what am I missing?
You are missing following section in web.config
<connectionStrings>
<!-- Connection String for SQL Server 2005/2008 Express -->
<!-- Connection String for SQL Server 2005/2008
<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />
-->
</connectionStrings>
The problem had to do with the role membership provider.
For some reason the AspNetSqlMembershipProvider provider falls back at the default one which is in the machine.config (insided the .NET folder).
In dev environments with an SQLEXpress instance running, the machine.config has a connection string named 'LocalSqlServer' which points to the SQLExpress. That's why it worked in my dev environment.
The server on the other hand, doesn't have SQLExpress, so no LocalSqlServer connectionstring exists in the machine.config and therefore the error pops up.
The workaround I found in DNN forums is to add these lines inside the section of the web.config
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=dbserver;Integrated Security=false;Initial Catalog=dbName;User ID=dbUser;Password=dbPass" providerName="System.Data.SqlClient" />
I'm creating a simple ASP.NET MVC 4 application using Entity Framework and code-first. With SQL Server Express 2012, everything works fine when using Windows Authentication:
<add name="dbConnectionString" connectionString="Data Source=(localdb)\v11.0; AttachDbFilename=|DataDirectory|myDb.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
However, when using the following for SQL Server Authentication:
<add name="dbConnectionString" connectionString="Data Source=(localdb)\v11.0; AttachDbFilename=|DataDirectory|myDb.mdf;Integrated Security=False; User Id=mysa; Password=mysapassword" providerName="System.Data.SqlClient" />
I receive an error:
"Login failed for user 'mysa'" ProviderIncompatibleException.
Am I missing something?
Is it possible that your *.mdf file is not attached to sql server instance?
Try attaching the myDb.mdf file to your database with SQL Management Studio and the change the connection string to
<add name="dbConnectionString" connectionString="Data Source=(localdb)\v11.0; Category=myDb;Integrated Security=False; User=mysa; Password=mysapassword" providerName="System.Data.SqlClient" />
and don't forget to give the appropriate rights to your user
I am trying to follow the tutorial on the building my first MVC application for here
all was good until I needed to run the application an entity framework should have done it's thing and create the data base for me, but for some reason I always get the same error :
The provider did not return a ProviderManifestToken string.
my question:
what are the necessary adjustments i need to do in order for the application to work?
here is my web.config file connection string section
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=Moran-Laptop;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="MovieDBContext"
connectionString="Data Source=|DataDirectory|Movies.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
I think your data source is not correct. Does it work with:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
If you inspect the exception you will find out that there is InnerException as well which most probably points to SqlException and its inability to find the database or server. Your ConnectionString expects that you have Sql Server CE database available in your App_Data folder. The tutorial that you are looking does not yet tell you that you have to add a new SQL Server CE database to your App_Data folder. Check part 5 of the tutorial http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part5-cs
First off you need to change your connection strings to point to the servers instance of sql server rather than to your laptop
in your connection strings replace Moran-laptop with "server-name\db name" i.e. r2008sqlserver\movies