R4ND3LL / EntityFrameworkRuler

Provides a reasonable way to do DB-first development with EF Core by allowing the customization of the reverse engineered model (i.e. scaffolding), including EDMX support for EF6 upgrades.
MIT License
21 stars 6 forks source link

Error on any EDMX #23

Closed Allann closed 1 year ago

Allann commented 1 year ago

Attempting to use the tool, and must be doing something wrong

---------------------------
Something went wrong
---------------------------
Error: Error parsing EDMX: There is an error in XML document (2, 2).
---------------------------
OK   
---------------------------

Steps: Load old .NET 4 Framework project using edmx v2.0.0 files Right click edmx and select 'convert edmx..' select path to core project (contains the design nuget package) click the 'Generate Rules' button.
receive the above message

I have left the 4 checkboxes unticked, but changing then doesn't appear to do anything anyway.

I have also confirmed that each edmx file currently works and will load fine in the project or an xml editor without issue.

Here is an example of the first few lines in case that helps

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
    <Schema Namespace="JTrackModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
        <EntityType Name="AdaptiveRoute">
MagicAndre1981 commented 1 year ago

maybe the tool only supports EDMX 3.0 files?

<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">

Change the version and try again. Or you use an old inbox EF4 or something like this. From what I see you need an EDMX for EF6

R4ND3LL commented 1 year ago

EFR doesn't look at the Version attribute. It parses the XML schema directly. Structure differences and/or namespace differences (ie. xmlns:edmx) will probably impact deserialization of the XML model.

If you supply a complete example of an old EDMX I may be able to assess the extent of the differences and see what's involved with adding support. Not making any promises though.

Possible tips on upgrading the EDMX first: https://stackoverflow.com/questions/20677994/how-to-update-edmx-file-version-2-0-to-3-0

Allann commented 1 year ago

Model.zip Here is a really small edmx file. If it isn't supported that is fine, we'll just find another way. Thanks for the link, i'll check that out tonight. and let you know how I go tomorrow.

Allann commented 1 year ago

We can't upgrade, the truck computers are running xp and can't be upgraded. So .net framework v4 is the best we got. :( having said that there are other edmx we can upgrade, but it might just be easier to redesign/refactor and take advantage of modern practices.

R4ND3LL commented 1 year ago

I just added "support" for edmx v2 on EFR 1.2.26.

all i did was incorporate a simple (automated) namespace mapping and the sample supplied is deserialized fine. A major warning here though, mileage may vary with model accuracy. If there are more structural differences than namespaces note that I have not accounted for them. The sample edmx did produce a good json file tho.

Allann commented 1 year ago

Thanks heaps.