Proper way to flush database in MVC 4 test application? - asp.net-mvc

In the past I've deleted the .mdf file found in App_Data but that's caused problems for me. So what's the proper way to completely flush the database?

Related

Visual Studio: The system cannot find the path specified

I am developing a website in ASP.NET MVC in Visual Studio. I'm trying to add a Database connection, but it gives me the error "The system cannot find the path specified".
Here's what I am doing:
Right Click on Models Folder
New Item > ADO.NET Entity Data Model
EF Designer from Database
New Connection (SQL Database connection test succeeds)
Choose the tables I want to include
Press Finish
Error Appears
The Output Window says the following:
Generated model file: Model1.edmx.
Loading metadata from the database took 00:00:01.3576925.
Generating the model took 00:00:01.3134936.
However, the Models Folder is empty and no connection strings are made. I have been trying for about an hour and nothing, deleted the .vs, bin, and obj folders, rebuilt the solution but nothing works. I appreciate any help you can provide.
After much troubleshooting, I managed to fix the issue, details below:
Delete Models folder (backup any files inside)
Create a new empty Models folder
Add the new Model
Hope this helps anyone with this issue.

Unable to open sql store file used in iOS application

I am using a sql based database in one of my application with Core Data framework. I have not enabled any file protection for persistent store (using NSFileProtectionKey). But I am unable to open my database file store in a directory under 'Caches' folder in Library.
Have you ever come across such an issue. Below is the image I am getting when I try to open the sql file. However, a difference from iOS 6 I could see in that folder is there are two additional files (-shm and -wal) present with the same name of the sql store file.
Could anyone please help me to find a solution to open the file.
The -shm and -wal are journal files created using write-ahead logging. You need all 3 files for a complete database. I haven't seen an encryption error falsely triggered by not obeying this rule, but it doesn't seem out of the question.
See https://developer.apple.com/library/mac/qa/qa1809/_index.html and http://asciiwwdc.com/2013/sessions/207.

Asp.net MVC, adding edmx gives trusted zone warning

I have an ASP.net MVC 4 project I am working on and am trying to add an ADO.net EF model to it using Database First.
The creation of the model (.edmx file) seems to run successfully and I am left with the desired .edmx model file in the folder I specified. However, I don't appear to be able to see any of the files nested under this model. (From all my research, I should be able to expand the .edmx file and see *Context.vb, *Designer.vb, *.edmx.diagram and *.tt files underneath, but I cannot.)
It should look something like this in the msdn article about Database First (see Step 4):
Upon noticing this issue, I discovered a handful of warnings that appeared after creating the .edmx model, one of which is (I have obscured part of the full path):
The path 'P:\IT\...\DAL\EF.Utility.VB.ttinclude' must be either local to this computer or part of your trusted zone. If you have downloaded this template, you may need to 'Unblock' it using the properties page for the template file in File Explorer.
The project is stored on a network share on one of our servers so it can be included in our daily backups and Windows Shadow copy also. My understanding is that the above warning has appeared because of this and I need to set my machine to trust this location.
I have tried all possible variations I can think of of
this MSDN article
but to absolutely not success at all, the warning remains.
Either I am looking in the wrong place, or I have missed something.
Does anyone know what I can do to remove this warning and gain access to the objects nested below the .edmx model?
Perhaps this could be of some assistance. I've never really dealt with trust issues working across the domain. I lean towards pulling down and working with a local copy.

Massive Temp Files Being Generated By Application - ASP.NET MVC/IIS 6

I just recently put an ASP.NET MVC application I developed/tested/etc up to my company's production server (IIS 6). However, it is generating some massive temp files (up to 1GB!), which is a problem, since the server is running a 2GB partition.
UPDATE: MORE INFO:
The temp files are being put into the c:\windows\temp directory
Is this normal behavior? If not, what possible causes could there be, and solutions.
If it is normal, what is the best way to overcome it?
Thanks,
Jack
Looks like your code maybe posting/saving some of the uploaded file cache in the temp dir.
Try commenting some code out that does the upload/saving and see if it still making temp files.

MVC and files uploaded by user, where to store files?

I'm having problems with deciding where to store files uploaded by user in my asp.net mvc application.
I've been using asp classic for about 10 years now, and always stored my files on disc at the site, and storing filename and folders in database.
How would you guys approach this problem?
Having them in database, and might get performance issues there? or leave it the way I always done it, and might get problems with "sync" filesystem and db?
I must have some sort of relational info in the database, so I cant store them just on disc
I'm using sql 2005 atm, and I read somewhere that sql 2008 has some sort of datacolumn now that just stores a "pointer" (like the text-datatype) to a file on disc, is that the way to go?
In some way, database is called a database for some reason, so not sure why invent wheel again? :)
Any pointers or ideas would be appreciated, I guess I'm just wondering about problems I might run into if I go with the database-approach
/M
You could use the special App_Data folder to put uploaded files and store the path into the database. If you go with SQL Server 2008 then you could take a look at the FILESTREAM type.
I'm not sure if your web application is load balanced or not, for the file management systems I've built in the past, I have always stored my files on a SAN or a network shared drive so they are accessible to all web/app servers. In addition, rather than storing the files as is, I always change the file name and type before I persist them on the file system (I typically use a GUID as the file name and a random file extension). Lastly, I would store the original file information in the database the files can be moved or copied logically rather than physically.

Resources