c# - Which method in EF5 is in charge of creating database -


i have couple of questions:

  1. in ef5 code first api method in charge of checks if database exits, , if it's not case method creates database?

  2. if use ef code first dal project , want ef generate other database testing purpose can using ef? i've changed initial catalog in connection string check if creates other database not , threw exception

  3. by using ef code-first or database-first, have dbcontext class, ef5 how knows used method it's internal actions?

thanks.

api check if exists context.database.exists(); , context.database.createifnotexits();

as access ef context starts doing things. there default behavior can manipulate things.

a context can open again different db instances yes. can use create different dbs on same server. careful use of constructor , corresponsing api.config setting required.

<connectionstrings> <add name="youcanhavemanyoftheese"      connectionstring="data source=localhost;initial catalog=different dbname ;integrated security=true;multipleactiveresultsets=true;app=entityframework"      providername="system.data.sqlclient" /> 

also
check out database.setinitializer();

ef knows if created db, or migrated db. actions recorded here. [dbo].[__migrationhistory]


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -