Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

edmx populating mdf?

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

like image 368
Rakka Rage Avatar asked Dec 31 '25 22:12

Rakka Rage


2 Answers

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.

like image 138
JasperLamarCrabb Avatar answered Jan 04 '26 17:01

JasperLamarCrabb


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....

like image 26
JWP Avatar answered Jan 04 '26 17:01

JWP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!