I'm creating a new MVC 3 pilot application using Mvc3 and the MvcScaffolding NuGet, everything runs smoothly until i want to use the database i already have. The application keeps creating a database with the format:
projectname.Models.projectnameContext
I'm stuck in here, my connectionStrings is:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="EnginesTrackingEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=WARCHLAPPY\SQLEXPRESS;initial catalog=[EnginesTracking];integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
In which specifies that my database is EnginesTracking.
Update
I'm following the database first approach from this example.
I have everything working perfectly but when the application starts, it creates a new table instead of using the one i specified.
The only one difference is that there is no databaseEntities
in my project, instead there is projectContext
for which i cannot do the number 8 step
Update2
I'm kinda given up on this, going to follow codeFirst approach as this is taking to much time for only being a pilot.
This is the Model1.context.cs:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ErrorReportingSystem.Models{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class EnginesTrackingEntities : DbContext
{
public EnginesTrackingEntities()
: base("name=EnginesTrackingEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Engine_Part> Engine_Part { get; set; }
public DbSet<Engines> Engines { get; set; }
public DbSet<Error> Error { get; set; }
public DbSet<Has_error> Has_error { get; set; }
public DbSet<Locations> Locations { get; set; }
public DbSet<Operators> Operators { get; set; }
public DbSet<sysdiagrams> sysdiagrams { get; set; }
}
}