2

I'm new to Entity Framework, and I have an existing database that I'd like to add a few tables to, rather than creating a database from scratch for my new tables. Is this possible with Entity Framework?

I've looked through the following MSDN articles on Code First development, and haven't been able to find the answer to my issue:

Code First Development

Code First Conventions

Code First Fluent API

Code First Data Annotations

2 Answers 2

1

I have had the same experience with my asp.net mvc3 project, it's a little different from asp.net but I guess entity framework is the focus here.

  1. create new table in sql server

  2. create corresponding model in your model project

  3. Add the new table object property in DbNameEntities.cs

    public DbSet NewTables { get; set; }

  4. In Application_Start() method, comment out the original code first approach

    System.Data.Entity.Database.SetInitializer(new SeedSampleData());

replace with this:

System.Data.Entity.Database.SetInitializer<DbNameEntities>(null);
Sign up to request clarification or add additional context in comments.

Comments

0

Yes, this is certainly possible.

A decent walk-through is available on Scott Gu's blog

Comments

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.