I am unsure about how to best resolve this issue. I have been working on a MVC application that requires user authentication, so I set up the project to use individual accounts, all well and good, it works fine.
However it saves the account data into a local db instance. I am at the stage where I want to host the application on a amazon web server I am renting. Publishing it to here has been fine, but now it can't connect to the local db so the sign up / register is no longer working.
My question is, can I somehow take this local db with me to the server, or do I need to generate a SQL script from it and deploy it on a local instance of SQL Express, and if so, how? I have had no luck with my attempts at either and would greatly appreciate any help.
Thank you.
I've never done this as Local DB is not recommended for anything in production so I'm not sure if it's allowed in AWS. In Visual Studio at the top of the solution explorer window there is a button to "Show all files" you should then see the hidden MDF local db file within the App_Data folder. Ensure that this file is being published to AWS.
Related
experiencing an odd issue I've yet to see on any of my other machines. This is a fresh laptop, so I have installed VS 2017, SQL Server 2017 express, then created a quick sample project using one of the stock .net core projects (with authentication stored "in-app"). This, of course, creates some basic entity migrations and DB context.
When I run I'm getting access denied errors. So, of course, I checked SQL service default user which is an admin. I then run basic migration commands and receive this
So, of course, my next step was to double check the default data locations of SQL since it appears to be trying to store it in C:\Users root?! I have never had to bother touching this during install, but worth a look. And of course, they are as I expected in their default locations of C:\Program Files\ etc
Rapidly running out of things to try at this point - and considering this is a fresh windows 10 install, with bare-bones vs 2017 and SQL express 2017 it feels a lot like a bug here. Everything is a default if you were to File -> New Project -> .NET Core Web Application with INdividual accounts.
Anyone have any thoughts or things worth trying? Why is it trying to store my DB in C:\Users? Connection string -
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-WebApplication3-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"
Thanks!
-Marc
You are not using SQL Server Express.
The local string says (localdb), which is the SQL Server engine running in user space. This is a big difference. Usually SQL Server or SQL Server express runs as service. (localdb) is not an alias for localhost (loopback address). It's a special name for a minified version of SQL Server which runs in user space.
When SQL Server runs as a service, it needs to have read/write permissions to the folder it writes. This is usually NOT THE CASE when the file is located within the User folder.
LocalDB on the other side, is always started when you start debugging your application and runs with the permissions of the user. So if your file was created by an admin user or outside of a directory you have write permissions.
Also, when you mount a database to SQL Server (Express), then the file is protected from write access to other applications, so LocalDB can't open it neither.
LocalDB is made for development to offer most of the SQL Server features but without all the hard setup and permanently running service in the background.
Essentially you have two options:
Use the SQL Server connection string as #TanvirArjel suggested
Detach the database from SQL Server express, copy it to your user folder (C:\Users\<myusername>\) and then correct the path to it
Then it should just work.
Notice that LocalDB is not meant to run in production, so you will likely experience issues when trying to run it in IIS (IIS Express and Console applications and WPF work fine).
Reasons for LocalDb not working with IIS is because ASP.NET (Core) applications within IIS run with a special user, but LocalDbs are always created in the users profile folder. Now, the accounts used by IIS don't have a profile and can't create the database and can't access any database outside (since localDbs are stored in user folder only the user who created it has access to it).
Here some source on it and the reasons behind it.
Using LocalDb with IIS
Write the connection string as follows.Hope it will work...
"DefaultConnection": "Server=YourPcName\\SQLExpressInstanceName;Database=aspnet-WebApplication3-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"
We have a development server that is running TFS 2010, it is working fine however we have a bit of issue:
We have a file (a class file) that contains a connection string that helps the application to connect to database, each user has its own database, I mean sometimes the developers needs to connect to other servers while this specific file is locked by other users in other machines. therefore at the same time different users are trying to change this connection string!
I know I can save the connection string in a file which is not part of TFS or I can allow checked in item to be edited, however I would like to know if there is anyway that I can add this class file to our TFS and everyone is be able to get it from the server but only when they want to edit it, it should not get checked out by TFS, only in their local repository it changes.
Thanks
If this is a web application then you can add the connection string to the web.config and have both a development and deploy mode. If all of the developers connect to a db server running on their local box you only need the one setting for all of the developers. If you need different settings for local | integration | quality | production environments you can use the built in visual studio configurations.
It is standard practice to require all of the developer local computers to be configured the same.
I deployed a simple ASP.net MVC application on IIS (7.5 under win 2k8 R2 64 bit), and it created its databases (ApplicationData and the second one with my own data) when I started using the app.
The databases (.mdf and .ldf files) were created inside App_Data folder.
Application uses entity framework code first approach. I had to change the app pool's identity to Network Service to get the webpage working. I also had to manually create this App_Data directory and assign permissions for Network Service user to modify it's contents.
Now the problem I got is that I can't see those databases in Management Studio (got SQL server 2012 express with advanced services installed). I can attach them manually if not using the webpage for a longer time, otherwise the .mdf files are locked by sqlservr.exe process of Network Service user.
All the time I got two simultaneously running sqlservr processes. One is run by MSSQLsomething user and the second one by Network Service. However, I got only one instance of SQL server installed (I'm 100% sure of it).
Could anyone explain me how is that possible that Management Studio cannot see those databases even at the moment they're being used (locked by sqlservr.exe process)?
This is because the database is hosted in User Instance Mode, and therefore not actually attached to the 'official' database server.
In that article you'll see that this is enabled using User Instance=true; in the connection string. To switch it off you specify User Instance=false;.
I am a newbie with DotNetNuke and have been stumbling on how to deploy from the development server to the deployment server. For starters my development and deployment servers are one and the same machine. Here are the steps that I did:
DNN Setup
Downloaded DNN using WebMatrix.
Launched DNN and proceeded with the installation wizard, which is basically just testing the environment and then creating the DNN database.
After the wizard's installation launching DNN will now proceed to the Getting Started page
Added "localhost/dnn" in the site alias list
Moving to ISS
In IIS I added application (folder) DNN in the web root
I copied all the files from the original webmatrix path to the dnn folder in c:\inetpub\webroot making sure that the file/folder hierarchies are the same
Result:
When launching DNN using my browser I am directed to the installation wizard page instead of the Getting Started page. What am I missing?
Thanks!
Confirm that the permissions on the folder containing DNN are the same on your test server as they are on your development server. (I give Network Service read/write and IUsr Read/Execute)
Confirm that the application pool running your application has the proper identity (Network Service is suggested) and is running the proper .NET Framework version; based upon your question, I think you are set on this.
Gain access to your web.config file. You will see a ConnectionStrings section. You probably need to update the connection strings.
If your test server runs off of a different database than your dev server, figure out the connection string of your test server and update your connection string accordingly
You may be able to restore a .BAK file of your DB to your test server
If you do this, you will probably need to (in SSMS) edit your Portal Alias table to include the host name that you are using in your test server environment. Examples: Maybe you access the site via localhost/ on your dev environment, but you access to test site via test.Ronald.com? test.Ronald.com would be your PortalAlias
If your test server runs off the same database server as your dev server, it sounds like you need to open up access in firewalls so that your test server has connectivity to your dev database
A word of advice
Once you get it running, you will be making changes to each database separately (assuming your test site and dev site use different DB Servers). This sync issue can be a royal pain with DNN, as your page structures, module assignments, html module contents, installed modules/extensions will get out of sync. While restoring backups is nice, it is not a very good long-term solution. I recommend database-syncing tools
The problem is most likely a problem with DNN not being able to find the Database. If it can't find the database, it will run the wizard in order to create one.
i have been having this problem and wondering if u guys could steer me in the right direction. i have created a web app, and i have the .mdf files in the App_Data folder. i have create a web setup project for this. everything installs 100%. But because the server( or machine ) that i install the project on doesnt have user instances because this is disabled by default. how then can i deploy a Database with my installer? bare in mind that this must be a simple installation process, as the end users 9/10 times will not have a DBA, or even knowledge of what a Database is?
Any Ideas?
Thanks in advance...
EDIT: Appearantly user instances are on by default, but only available in SQL Server Express 2005 and earlier. For it to work, it depends on the connection string, which you control:
Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Database1.mdf;
Integrated Security=True;
User Instance=True
You still have to make sure the web server has SQL Server Express installed; if they have SQL Server, you're screwed.
The full details can be found in this MSDN Article.
By the way, you know that user instances is a feature that's being deprecated?