0

Is there a way to have entity framework create a database to the users my documents folder with model first? I've tried a few statements in the DbContext's contructor but it keeps telling me that the database does not exist. This is a with 6.1.1 using a local database only with entity framework sqlserver compact. The only way I'm able to get a database created is manually in in the server explorer and have it made from the edmx generator but that won't work since the application will be installed on various machines.

1 Answer 1

1

Simply put, no. Database initializers and/or migrations only work with Code First, so your best bet is to generate SQL for your database and check if the database already exists during your application startup, then execute the generated script against the configured connection string.

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

1 Comment

Thanks I'll try that out tomorrow. Worst case ill use code first. I couldn't find any info on this.

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.