Change Schema of Entity Framework

I'm using Entity Framework 5 on ASP MVC 4 web site I'm developing. Because I am using shared hosting which charge for the number of databases I use I would like to run a test site near my production site.

I have two problems:

1) I use Code First and Database Migration. The migration classes seem to embed the schema dbo inside the name of the tables.

How can I change the schema according to the test/production flag

2) How can I change the schema from which EF select data?

Thank you, Ido.

Answers


Both migration and EF take schema from mapping so if you want to change the schema you must update your mapping to use:

modelBuilder.Entity<MyEntity>().ToTable("MyTable", "MySchema");

and control the value of MySchema from configuration but this is really bad idea. One day you forget to change the value and break your production. Use local database for development and test.


Need Your Help

HTML change URL after an action-invoking-URL was processed

javascript html ajax url

I find this problem hard to reword briefly in the title but this is what happens:

How can I unit test my WCF client class?

c# .net visual-studio-2010 wcf .net-4.0

I have a class library that interacts with a WCF service, and uses an app.config file for its configuration. I'd like to unit test this class, but when I run my unit test, I get:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.