Disabling EF table creation

0

In my application I am using EF6 to map into an existing database where I do not have control of the schema.

When the first Db call is made I get an exception where create table is not allowed, which its not and database initialisation should be disabled.

System.Data.SqlClient.SqlException (0x80131904): CREATE TABLE permission denied in database 'ADatabase'.

I have followed various methods of disabling initialisation using both code and config but none seem to be working.

https://msdn.microsoft.com/en-us/data/jj680699 https://msdn.microsoft.com/en-us/data/jj556606

I have tried implementing DbConfiguration for auto discovery, explicitly calling it in my Application_Start as well as Database.SetInitializer<MyContext>(null); in the ctor for the Context.

Config was set as per Database Initializers in the MSDN article linked above (sample below)

<contexts> 
  <context type=" Blogging.BlogContext, MyAssembly" disableDatabaseInitialization="true" /> 
</contexts>

Using EF 6.1.3, .NET 4.6 and SQL Server 2008

c#
entity-framework
entity-framework-6

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0