I want to know if I have sqlstate session then do I need to create database for aspnetdb in the already (i.e. sampledb) existed database or I should have to create it separately. Suppose if I had create it in sampledb which is already existed then what connection-string path should I have to give in web.config and what changes would I have to make it on the time of deployment of the internet.
Please give me answer because there is lots of questions arising in my mind.
You should create a new database for the session state.
Configuring SQL Server session state is really simple and requires two simple steps:
Install ASPState database on your SQL server.
1.1 Open the command prompt and navigate to the folder where .NET Framework is installed on your machine e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319
1.2 Run the following command in the command prompt - aspnet_regsql.exe -S SampleSqlServer -E -ssadd -sstype p
Configure SQL server session state in the Web.config file to point to the ASPState database on your server.
Web.config:
<configuration>
<system.web>
<sessionState mode="SQLServer"
sqlConnectionString="Integrated Security=SSPI;data
source=SampleSqlServer;" />
</system.web>
</configuration>
Complete tutorial can be found here - Session-State Modes
Related
I created a new ASP.NET web application in VS2017 as blank and installed Entity Framework in it and all important libraries.
Problem is:
I successfully ran Enable-Migrations
I successfully ran Add-Migration Initialize
But I can't execute update-database because I can't connect to SQL Server Express just from this project
I tried to open other project and it fork very fine
I think there is a problem in the web.config file because I start from scratch
I add a connection string as follows:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Server=OJ-PC\OJ_SQLEXPRESS;Database=OrdersDb;User Id=sa;Password=******;"
providerName="System.Data.SqlClient" />
</connectionStrings>
I tried a lot of connection strings. I get connection string from SQL Server and add it exactly. I tried same connection string that worked in other project but it didn't work in this project.
In two days I tried everything
Thanks for help!
The . (dot) alias is used when you deal with SQL Server Professional edition.
When it comes to dealing with SQL Express the server name consists of 2 parts separated by backslash \.
For instance
DESKTOP-3PQ45JH\SQLEXPRESS
In this case DESKTOP-3PQ45JH is the name of computer, SQLEXPRESS is the name of server instance.
I am running into an issue. I have developed a site in webmatrix with SQL server compact edition. My site is ready and I can see it run without any issue in my PC. However, I ran into an issue after migrating the database to SQL server. Migration finished successfully and I can see all my tables, data in the migrated database. But I can not run the page anymore. In IE browser, it gives me error Page cannot be displayed. (In other browsers it just tries to load indefinitely).
I don't know what is the issue. If I remove the migrated database file(.mdf) and put the .sdf back in APP_DATA folder and connect it in database workspace, my site starts working again.
Note: I can see a connection string added to web.config file when migration is completed.
Verify that you can connect to the migrated database from within SQL Server Management Studio(SSMS). Your connection string in the web.config file needs to be correct and should look something like:
<connectionStrings>
<add connectionString="Server=SERVER01;Database=mydatabase;Uid=user;Pwd=password" name="somename" providerName="System.Data.SqlClient" />
</connectionStrings>
After logging in through SSMS you will know what the settings should be. I hope this helps you.
Thomas, thanks for your reply. Glad to let you know that issue has been resolved. The issue was regarding the sql server version. Basically I had SQL commands like "fetch first n rows only" etc. Now, this is not supported in SQL 2008. My migrated database was in 2008. When I imported the data into SQL 2012 database, it started working now.
I'm lost with this, especially after following the guide on how to configure this.
This is how the webdeploy is configured in the iis host config:
<wdeploy>
<backup turnedOn="true" enabled="true"
numberOfBackups="4"
backupPath="C:\inetpub\Backups\{siteName}"
continueSyncOnBackupFailure="false">
<excludedProviders>
<provider name="dbMySql" />
<provider name="dbFullSql" />
</excludedProviders>
</backup>
</wdeploy>
As per the documentation:
What a Backup Contains (documentation)
"...You can change this default behavior by modifying the ExcludedProviders backup setting, or by specifying skip rules before doing a publish."
Web Deploy providers (documentation)
"Web Deploy dbFullSql Provider" The dbFullSql provider enables first-time publishing of databases from a local SQL Server development database to a remotely hosted SQL Server database.
When I go to deploy I get the following message:
Error: BACKUP_FAILED - Skipping backup because it failed due to an unknown reason. For more information, contact your server administrator.
Error: You cannot create or restore a backup of multiple databases in a single sync.
Error count: 1.
My questions/issues are why is the backup attempting to backup more than one database and why would this be even attempting to backup the databases when the provider has been excluded in the config.
Help!
We have a .NET 4.5 Azure Webrole with Azure (colocated) Caching enabled. We use Entity Framework 5.0 talking to an Azure SQL database.
We did some cleanup on our staging/testing and I noticed that the entity framework edmx file complains that
Entity type 'AspNet_SqlCacheTablesForChangeNotification' is not mapped.
We had also briefly experimented with SQL Sync. We don't know if it's SQL Sync or Azure caching that added that table (and any other elements?) to our database
What installs and uses AspNet_SqlCacheTablesForChangeNotification? Is it safe to remove it? Finally, any extra items that ride along with that table that we should cleanup?
See this article on MSDN on setting up SQL Server Cache Dependency.
This is set up using the aspnet_regsql.exe tool that comes with .Net
You can disable this using aspnet_regsql -S localhost -U sa -P wrox -d Northwind -dd however I am not sure if this removes the associated configuration tables (Worth a shot). The tool may not work with SQL Azure in which case you may have to manually remove the table.
It's worth checking your web.config is not set up to expect Cache Dependencies by checking for this:
<system.web>
<caching>
<sqlCacheDependency enabled="true">
<databases>
<add name="Northwind" connectionStringName="AppConnectionString1"
pollTime="500" />
</databases>
</sqlCacheDependency>
</caching>
</system.web>
I've got an application running on ASP.NET MVC 3 with Entity Framework Code First. In development I was using a SQL Compact database, however upon moving this to my virtual server, I am attempting to target SQL Express.
There were initially issues to do with a "CREATE DATABASE in master" error, which I got around by extracting the model from the SQL Compact database into an SQL script and executing that on the server to create the DB.
I have created a new connection string to point at the SQL Express instance, which uses the EF format:
<add name="LouiseClarkEntities" connectionString="metadata=res://*/Models.LouiseClark.csdl|res://*/Models.LouiseClark.ssdl|res://*/Models.LouiseClark.msl;provider=System.Data.EntityClient;provider connection string="Data Source=.\SQLEXPRESS; Initial Catalog=LouiseClark; User ID=<username>; Password=<password>"" providerName="System.Data.EntityClient" />
The error I am now getting when navigating to a page that uses the DB, is:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
I have installed Entity Framework 4.1 on the server to try and see if this would solve the issue, but it didn't seem to do much good.
Snippet from the stack trace on error page:
[ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.]
System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1420567
System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +35
[ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.]
Any help would be appreciated, as this has been bugging me for days now!
Thanks,
Chris
Use the normal connection string with code first.
<add name="LouiseClarkEntities" connectionString="Data Source=.\SQLEXPRESS; Initial Catalog=LouiseClark; User ID=<username>; Password=<password>" providerName="System.Data.SqlClient" />
On your second problem, and partly the cause of the first too...
what you did wrong is which I got around by extracting the model from the SQL Compact database into an SQL script and executing that on the server to create the DB.
You should use migration scripts for that - and use in PM console then Update-Database -Script to dump out what you need - then deploy that to the server Database.
Problem is that there are CF has its own table and data that needs to be initialized properly. If that doesn't match you'll end up with something like that.