0

I've got an existing database with just one table. This table's most important columns are username and password, and on my asp mvc project i have a model with complementary fields related to a specific user. I'm new to this technology, so here we go.

First question: Is it the same to add a connection to a sqlserver from the server explorer (left side in visual studio) than adding the .mdf file to App_Data. I've seen both on some tutorials, it's just that only the former is working for me and it doesn't appends the <add .. /> line to my Web.config file, the latter method throws an 'access denied' box.

Can you make a table from a model?. It doesn't matter if it's empty, or you have to create from sql-studio. This is for my already-coded model, i want it to end up on the same database as the other table.

I want to map models to tables, if is there a straightforward way to do this with a hard-coded config line (i'm done with tutos that do it with the designer), i think is the more sane method to get this code-first-db-first done.

ASP MVC 3, Visual Studio 2010 Profesional, Sql Server 2008 r2 Express

1
  • I assume you're using Entity Framework? This question doesn't really have much at all to do with ASP.Net MVC. You should tag the name of the ORM you're using. Commented Sep 4, 2012 at 20:08

1 Answer 1

1

I'm not 100% sure this is what you are looking for but why dont you just use the entity framework power tools and reverse engineer the code first model from your existing database, from then on you can just treat everything as if you are doing code first.

Also check out this link

Sign up to request clarification or add additional context in comments.

6 Comments

It would be the perfect answer if you could show how to configure the mappings between models and tables, now i just want to hard code an empty table and get the job done, but i'll try those tools as well.
I've tried scaffolding a model to generate the models from a table but i get a wierd error showing a class that has nothing to do with it, i don't trust wizards no more.
the tools will generate all tables in the database including some system tables that you might have to ignore/remove, the tool will generate the mappings for you
added another link that might help you customise the output from the generator if it doesn't meet your needs
I managed to make it that way, i think that i was afraid of the auto-generated code, thanks.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.