Question

when i 'generate database from model' in an edmx file it asks for a datasource and generates a sql file and adds the data source to the app.config

if i choose sqlserver as the source it works fine and i can either use an existing database or create a new one and the tables get populated to it and its ready to use

possible to make that sql populate a new mdf file somehow?

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 08/25/2010 10:41:33
-- Generated from EDMX file: c:\test\test.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [test];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

...

works fine against sqlserver but complains database not found when i connect to sqlexpress and to to populate a local mdf file in the project dir?

i have to make it use the connection string from the app.config somehow? or create the database in sql manager first? or modify the generated sql somehow (with the path of my created mdf maybe)?

thanks a lot

Was it helpful?

Solution

I tried running a query like this by right clicking on the local .mdf in the solution and choosing "New Query". I had to remove the "use [test]" and all the "GO"'s in the query text and it generated my tables correctly.

OTHER TIPS

I had to open the local db instance, copy the query to that window, click New Query and then execute it there. Funny thing is that the generated SQL allows you to right click but if you then choose Execute it just can't see to realize there is an attached MDF to the project....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top