c# - Multiple Database Files/Context ASP.NET MVC -


My understanding is that reference reference connects to a database through a connection string specified in web.config. When I create a new Scaffold, then this new database with a new connection string. Mdf file creates I'm coming from Rail Active with a database and a connection string. So why do asp.net do it differently? Why are there many database files?

In addition to making things easier for me, I changed the connection string of the user model to my default site database named Tonyius and kept the users in the same DB as everything -

  Public ApplicationDbContext (): Base ("ToolSite") {System.Diagnostics.Debug.Write (Database.Connection.ConnectionString); }   

and this causes an invalid object name 'dbo.AspNetUsers'. Exception Although the table exists in the AspNetUsers "ToolSite" database, do you need to change any other part in the server code?

The default MVC project scope is always a pet flock of mine when you create a new MVC project with auth , You receive a user model and an app reference to wire it. It is a great honor, because it allows you to immediately run this project with no additional configuration. However, he is stupidly the same In the CC file the user decided to insert model and application reference, so it does not make developers understand that thinking that setup has been linked from two.

In fact, MVC applications are designed for the same context, and instead of actually making a new, different reference, you should add your model to the existing context that Scaffold has made. The only reason for multiple references is that if you are really working from several databases, and then only because you deal with the existing database in addition to your application-specific database in other words , You should have only one reference that is tied to the migration and then you can not create additional references that are database-operated on the first basis. Once you understand that it becomes less confusing to work with a loft project.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -