none
.MDF not created in my project RRS feed

  • Question

  • Hello,

    I am creating a C# WPF project with an ADO.NET Entity Framework connection using Database First. I created the model (.edmx) but I do not see the .MDF created. I'm using VS 2017 and my database is on SQLExpress.

    Thank you,

    - Justin


    Tuesday, November 6, 2018 1:34 PM

Answers

  • Hi, I created my db in SQLExpress prior to doing anything else.

    I'll assume you mean MS SQL Server Management Stuido, a MS SQL Server database administration tool, that allows one to create the database and tables for a given database hosted by MS SQL Server and Express versions.

    After doing this I saw no .MDF in my solution explorer (just the .edmx). Is this normal?

    No you are not going to see a MDF file, becuase it is attached directly to the DB Engine,  and it is sitting in the Data directory. And you would have to use Visual Studio's Server Explorer, made a connection to the database and use the limited DBA tools to administer the database, which is similar to using MS SQL Server Management Stuido aka SSMS.  

    C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA

    From tutorials I saw and following along step by step I was expecting to have a .MDF file just like they did in the tutorial I watched.

    I don't know what tutorial you watched, but most likely, the tutorial was using some form of Localdb as to why you saw the MDF file. Normally, the MDF files are in the above directory attached to the DB engine.

    VS's Service Based Database is one way to make a detached standalone MDF file that will use Localdb, a limited DB engine version of MS SQL Server Express for standalone MDF files. Of course,  you could use SSMS,  detach the database from the DB engine, move the MDF file to some director and use Localdb.   

    I gave you a link about Localdb. Normally, you will take a detached MDF file after standalone development against the MDF, move it the Data directory and attach the MDF file to the DB full feature engine using SSMS.

    I was wondering if anyone else has experienced this or if maybe the .MDF isn't needed at all?

    The MDF file is a MS SQL Sever database file. It is an individual database that is attached or detached from the MS SQL Server DB engine. The MDF file can be attached to a the Server version of MS SQL Server too.

    MS SQL Server is not Access.

     https://www.udemy.com/microsoft-sql-server-101/

    You can also get help for MS SQL Server Express at its MSDN forum.

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlexpress

     There is also the EF forum.

     https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    There is also the VS forum that can show you how to use Server Explorer so that you can connect to MS SQL Server to administer the database or connect to Localdb to administer the database from within VS. 

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio


    • Marked as answer by Justair07 Tuesday, November 6, 2018 6:25 PM
    Tuesday, November 6, 2018 5:49 PM

All replies

  • EF DB First works with an existing database. It means you would have had made the debase yourself through MS SQL Server Management Stuido. The database would be attached directly to the DB engine. 

    Or you can let VS2017 make a detached MS SQL Server Express MDF file that you can point to and allow EF DB first to connect to the MDF file and create the edmx, which is called Service Based Database.

    https://docs.microsoft.com/en-us/visualstudio/data-tools/create-a-sql-database-by-using-a-designer?view=vs-2017

    I am confused becuase you would have had to have gone through using the EF DB first wizard to even make an edmx to even use along with it creating the C# classes that represent the virtual object model that EF would use in the C# code. 

    Understand that you will be using Localdb when using the VS2017 Service Based Database with localdb being based on the version of SQL Server Express installed.

    https://blogs.msdn.microsoft.com/sqlexpress/2011/07/12/introducing-localdb-an-improved-sql-express/

    Tuesday, November 6, 2018 2:02 PM
  • Hi, I created my db in SQLExpress prior to doing anything else. Then I used EF Config Wizard to create the model of my database in VS. After doing this I saw no .MDF in my solution explorer (just the .edmx). Is this normal? From tutorials I saw and following along step by step I was expecting to have a .MDF file just like they did in the tutorial I watched. I was wondering if anyone else has experienced this or if maybe the .MDF isn't needed at all?

    Tuesday, November 6, 2018 4:31 PM
  • Hi, I created my db in SQLExpress prior to doing anything else.

    I'll assume you mean MS SQL Server Management Stuido, a MS SQL Server database administration tool, that allows one to create the database and tables for a given database hosted by MS SQL Server and Express versions.

    After doing this I saw no .MDF in my solution explorer (just the .edmx). Is this normal?

    No you are not going to see a MDF file, becuase it is attached directly to the DB Engine,  and it is sitting in the Data directory. And you would have to use Visual Studio's Server Explorer, made a connection to the database and use the limited DBA tools to administer the database, which is similar to using MS SQL Server Management Stuido aka SSMS.  

    C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA

    From tutorials I saw and following along step by step I was expecting to have a .MDF file just like they did in the tutorial I watched.

    I don't know what tutorial you watched, but most likely, the tutorial was using some form of Localdb as to why you saw the MDF file. Normally, the MDF files are in the above directory attached to the DB engine.

    VS's Service Based Database is one way to make a detached standalone MDF file that will use Localdb, a limited DB engine version of MS SQL Server Express for standalone MDF files. Of course,  you could use SSMS,  detach the database from the DB engine, move the MDF file to some director and use Localdb.   

    I gave you a link about Localdb. Normally, you will take a detached MDF file after standalone development against the MDF, move it the Data directory and attach the MDF file to the DB full feature engine using SSMS.

    I was wondering if anyone else has experienced this or if maybe the .MDF isn't needed at all?

    The MDF file is a MS SQL Sever database file. It is an individual database that is attached or detached from the MS SQL Server DB engine. The MDF file can be attached to a the Server version of MS SQL Server too.

    MS SQL Server is not Access.

     https://www.udemy.com/microsoft-sql-server-101/

    You can also get help for MS SQL Server Express at its MSDN forum.

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlexpress

     There is also the EF forum.

     https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    There is also the VS forum that can show you how to use Server Explorer so that you can connect to MS SQL Server to administer the database or connect to Localdb to administer the database from within VS. 

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio


    • Marked as answer by Justair07 Tuesday, November 6, 2018 6:25 PM
    Tuesday, November 6, 2018 5:49 PM
  • Wow. I really appreciate you breaking that all down for me. I would reference the tutorial I used but it's on Lynda.com which is a paid site. I am in deed using a localdb for my development. Thank you for the links because I plan to move everything to our business VLAN once I'm done developing and testing.




    Tuesday, November 6, 2018 6:25 PM