none
Create database with EF and SQL Server Compact RRS feed

  • Question

  • I was wondering what the proper way is to create a database using code first and SQL Server Compact. In articles written by Julia Lerman she creates a database by creating a separate project that has all entities in one context. I was wondering if there is a different way to create the database from multiple bounded context's.

    I am creating a desktop application in which the state of the application is saved to a file much in the same way that Microsoft Office products save their data to individual files.  I was thinking entitiy framework and SQL CE would be a solution.  Please let me know if this is a good path or if I should instead use XML of binary serialization.  Also, is SQL CE the correct choice or should I use LocalDb.  If the later, then does localdb provide a way to change the file extension to one that my application is using?

    John

    Saturday, February 1, 2014 5:23 PM

Answers

  • >> Is it possible to change the extension on the file?

    Do you mean that you want to the .mdf to others? No, this is impossible, after being changed, the file will not be recognized any more.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by jfras2009 Friday, February 7, 2014 4:45 AM
    Thursday, February 6, 2014 5:43 AM
    Moderator

All replies

  • Hello,

    >>Please let me know if this is a good path or if I should instead use XML of binary serialization.  Also, is SQL CE the correct choice or should I use LocalDb.  If the later, then does localdb provide a way to change the file extension to one that my application is using?

    If it is a desktop application, it is recommended to use the SQL Server Compact:

    Microsoft SQL Server Compact is a compact database ideal for embedding in desktop and web applications.

    See it here.

    And for Code First with SQL CE, there is a sample for it:

    http://www.codeproject.com/Articles/680116/Code-First-with-SQL-CE

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 3, 2014 6:17 AM
    Moderator
  • I have read that SQL CE is being deprecated and developers should use LocalDb is this correct? If so, how can I create a LocalDb file with my application extension.
    Tuesday, February 4, 2014 1:22 PM
  • >>how can I create a LocalDb file with my application extension.

    If you want to work with a local db to create a database using Code First, please refer to link below:

    http://msdn.microsoft.com/en-us/data/jj193542.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 5, 2014 8:06 AM
    Moderator
  • Dear Jfras

    Thank you for the posting.

    Please visit this link it may help you

    http://msdn.microsoft.com/en-us/data/jj200620.aspx

    http://msdn.microsoft.com/en-us/data/jj193542.aspx

    http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

    Thanks

    Wednesday, February 5, 2014 8:12 AM
  • I seen that article.  However, I cannot seem to change the extension on a LocalDb file.  Is it possible to change the extension on the file?

    Wednesday, February 5, 2014 3:50 PM
  • >> Is it possible to change the extension on the file?

    Do you mean that you want to the .mdf to others? No, this is impossible, after being changed, the file will not be recognized any more.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by jfras2009 Friday, February 7, 2014 4:45 AM
    Thursday, February 6, 2014 5:43 AM
    Moderator
  • Yes that is what I am asking, can I change .mdf to some other extension like I can do with SQLCE. I guess this is not possible according to a comparison between SQLCE and LocalDb.

    Thanks

    Friday, February 7, 2014 4:45 AM