Database recreated everytime Application runs - asp.net-mvc

Good day guys,
I noticed my application deletes database structure and re add new one everytime i Run my application.
The DBset uses DropCreateDatabaseIfModelChanges. I have read about the other options like CreateDatabaseIfNotExist. is there any other option to force it from recreating database?
And also with throwing any exception of error?

I have been able to resolve this by using Code First Migrations

Related

MVC VS Template with Authorization: When is the database file created?

The template comes without database at first. When I launch the application some code must create the db obviously, because I check the appData folder and now it's there.
Can you tell me which part of the code creates it? Thanks. I have long looked at the code and I cannot figure it out.
I think the only answer possible is that entity framework creates the database automatically. But the strange thing is if I remove thee database it does not get recreated, I get an error that says it's missing it.

Table Updates Made in SQLiteStudio Not Recognized by iOS Mobile Application

I am working on a iOS mobile application using Xcode as the IDE and Swift as the language of choice. I added a column to the SQLite database that interacts with my application but unfortunately when I attempt to perform any database operations through the application the column is not recognized.
The following error is sent:
DB Error: 1 "table xyz has no column named column_name"
When I added the column I also increased the database version or user_version in SQLiteStudio.
Is there something else I should be doing to cause the application to recognize the changes? I know uninstalling and reinstalling would work but that is not an option of course as I cannot lose the data currently housed in the database. My other idea was to put all the data in temporary variables or something like that, drop and recreate the tables and reinsert the data. I wasn't sure if this was a good course of action though. Any help with this is appreciated.

Invalid Object Name in MVC DB First app

I'm running into a frequent MVC DB first issue where everytime I update my domain model classes from the DB, something always seems to be breaking. In this case, after adding another table and model into my project, running Update model From Database and Generate Model From DB in the .EDMX file, a perfectly good table with a working query is causing the Invalid Object Name error when the app runs in the browser.
I've cleaned and rebuilt my project multiple times. Everything compiles and the error only occurs when the app tries to run in the browser.
Is DB First prone to being buggy or am I not doing something properly when using DB first approach?
Error Screens

How can I update over a linked server with code first migration?

I am using entity framework 6 with code first. During deployment I need to make an update across and existing linked server. When I try this I get:
"MSDTC on server 'myLocal' is unavailable."
This problem happens when running agianst my local instance. MSDTC is not enabled on that instance but I have no trouble running this update manually in SQL Server. I don't want every developer to have to enable MSDTC for this one command.
I have tried adding this as a migration using a DbMigration.Sql and I get the error. I have also tried it in the seed method of DbMigrationsConfiguration using context.Database.ExecuteSqlCommand and I get the error.
ADO.NET Transaction scopes that go across servers - including linked servers - will automatically start the Distributed Transaction Coordinator (DTC). I think your best bet is to update the other database with a direct call in the migration, rather than through the linked server.

Changing connection string from dropdown

I created a basic MVC app to do CRUD operations on database tables. I'm using Entity Framework Database First, so I was able to just scaffold out controllers and views very quickly.
We have a dev, qa, and prod database. The schema should be identical with only the data in each being different.
I want to create a dropdown that will let me change the connection string from the app. I'm not sure the best way to do this. It currently works just fine using the dev connection string, but if I manually change the database to qa from web.config, whenever I try to create or update an existing record from the app, I get this error:
"The UPDATE permission was denied on the object"
I don't get this error using the dev database.
The problem is with your database permissions.
Use the following link and go through the security/permissions and you will be able to solved the problem.
http://blog.sqlauthority.com/2012/04/23/sql-server-introduction-to-sql-server-security-a-primer/
Please verify that your user has the same permissions on qa/prod as it does in dev.

Resources