Migrations Error in MVC 5 project - asp.net-mvc-5

Im develop the MVC project, i have a some issue for this , im already to created database , but i cant update DB in add PM> Update-Database method,
displayed the following error , how can i fix it?
No migrations configuration type was found in the assembly 'MVCMovei'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
Thank you

In the package manager console run the following command
Enable-Migrations
After that run Command
Add-Migrations "AnyName" (initialmigration etc)
After that Run
Update-Database (if you want to make changes in database)

I came across this issue whilst working on MVC Movie App tutorial too. Using MS Visual Studio Nuget Packet Manager(PM) do the following;
PM> Enable-Migrations
Checking if the context targets an existing database...
Code First Migrations enabled for project MVC Movie.
PM> Add-Migration Initial
Scaffolding migration 'Initial'.
PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201808240707259_Initial].
Applying explicit migration: 201808240707259_Initial.
Running Seed method.
To follow these solution in detail use these resource from MS Docs. I hope this help other starters on SO who get stuck.

Related

How to do the Authorization in Asp.net by using Identity Framework?

For doing authorization in asp.net mvc 5 I have searched lot on internet but not getting correct answer. Actually I am using Visual studio community edition with .net framework 4.5.2 and mvc5. I want to do the Authorization in my project. My project is created with no authentication mode while creating a project.
Firstly I have tried these things:
I typed a command "Enable Migrations" on Package manager console.
Then I got one error like: Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel.
I dont know how to resolve this error. please help me to get out of it.
Which approach did you chooses to build our database model? Code First, Model First or Database First?
I'm asking because you can't use migrations with Model First or Database First approach. EF Migrations is a product targeted for Code First approach. CodeFirst assumes that you will never make any changes manually to the database. All the changes to the database will go through the code first migrations.
But there is solution for that - you can use Code First approach with an existing database. Take a look here: Using EF “Code First” with an Existing Database.

JHipster Mini Book Tuto fail, like other

Trying to setup an app with JHipster. Every tutorials I follow I have errors and failures.
Whatever options I select I got errors on my project.
Following the JHipster MiniBook procedure I have error like this on my IDE at start:
http://imgur.com/bWdek5W
And when I follow the directives to page 24 and try to run
./gradlew bootRun
I got a build failed: http://imgur.com/jFeJEQ6
I don't know what I'm doing wrong. I follow step by step the book, or other tutorials. Something must be wrong configured on my computer.
Any idea ?
Just looking at the error messages which are shown:
On the first screenshot you have configured your IDE to use Java 1.6 source code. JHipster is using Java 1.8, so the lambda expressions (which are new in Java 1.8) cannot be compiled.
On the second screenshot you have configured JHipster to use an external database. But you have not followed the documentation, which tells you to configure that external database in your application-dev.yml configuration file (and to start the database, of course!)

project creation error in super sonic framework

I am new to work on super sonic framework. I have to create API for the android app on it. So I install the Git and nodejs in my system. Now I am trying to create project so I have used the command on Git command prompt
C:\Program Files\Git>steroids create Project1
but I am getting error when I run that command. I have attached error's Image. How can I remove that error and create the project. I am new on it so I want to know that can I create API for app without creating own app and installing the framework. If yes, then How? Actually I need to create API for the android app.
I don't think Run should be capitalized. Try using run.

VS2012 Database Project Validation

I've set up a new Visual Studio 2012 Database Project to hold the assets for a database and I'm having problems getting the project to build properly. The issue that I'm facing is that we have custom code within our database scripts that does certain evaluations when executed. This is by design, and works well. However because it's more complex than the standard database script (for say a table) the project won't build. I'd like to turn off the validation so that the project can build and deploy without being failing the build. Is there a way to turn off the validation portion of the project? I'm new to working with DB project types in VS, so not sure what all may be available. Any other strategies or work-arounds are also welcome.

model backing the context has changed since the database was created. Consider using Code First Migrations to update the database

I am using MVC5 and EF6 CodeFirst migrations. My model is in a separate project from my MVC web app and I keep getting this error when trying to access the model classes. I have automatic migrations already enabled. I can drop the entire database and then using update-database to regenerate everything I still get this error. The error is wrong because the context has not changed since I created the database. Also, through a Unit Test project, using the same calling code as I have in my MVC app, I can reference the same Model project, access the model classes and data. I have the Model separate from the MVC project because I need to be able to reuse the Model outside of the web.
The model backing the "xx" context has changed since the database was created. Consider using Code First Migrations to update the database
Database.SetInitializer<DbContext>(null);
http://patrickdesjardins.com/blog/the-model-backing-the-context-has-changed-since-the-database-was-created-ef4-3
I got a similar problem :
The model backing the 'ApplicationDbContext' context has changed since
the database was created. Consider using Code First Migrations to
update the database
I have one project for MVC and another project for the model, context and repositories. I've been working on it for weeks but today it said stop.
I have tried to delete database, enable-migration, add-migration and update-database so many times that I've lost count. I've added initializers to MigrateDatabaseToLatestVersion as well as DropCreateDatabaseIfModelChanges.
What finally made it work was to move model, context and repositories into the MVC project (not something I was keen on)...then it worked right out of the box without any code changes at all (besides namespaces)! Very strange...
I've read so many blog posts during the day trying to solve this problem. One of them (I don't know which one) mentioned a bug in Visual Studio 2013 where reference to DLL files weren't always updated as they should, suggesting that my MVC project missed out something when I was running add-migration and update-database in my separate project. But it's just a guess.
I'm using EF 6.1 and .Net 4.5.1 in my solution.
Just to elaborate on RouR's answer:
I had an MVC web project that had a model attached.
I then created a console app that consumes this model.
My console app, only is aware of the connection string and has EF reference, just doesn't know how to let each one communicate.
Hence, the model backing database changed error appears
The engine is just confused how to proceed it sees and expects an entity, as was reference, just losses it when it fails to find the proper context, and assumes context wan't migrated properly.
So here we are,
Database.SetInitializer<MyProject.Models.MyModel>(null);
We are having the same issue. What solved it for me was not necessarily to move the Model, Context into the MVC project, but move my seperate project to the same solution as the MVC project and reference it by project folder.
This worked, but referencing a DLL instead of a project did not work.
Funnily enough, when creating a new Console Application and referencing the DLL assembly, we did not get this issue... only from an MVC project
We use EF code migrations to keep databases schemas up to date. The other day I had the same problem, in my case I was working with 2 database instances (QA and DEV databases of the same client with exact same data however QA environment was throwing this error. I've fixed the problem by deleting the _MigrationHistory folder and problem solved.

Resources